当前位置:网站首页>1007 maximum subsequence sum (25 points) "PTA class a exercise"
1007 maximum subsequence sum (25 points) "PTA class a exercise"
2022-07-02 20:32:00 【Yang tree Yang tree】
Try one by one , Pay attention to special situations , For example, all negative numbers
#include <cstring>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#define dd double
#define PII pair<int,int>
#define int long long
#define ll long long
using namespace std;
const dd eps = 1e-6;
const int mod = 998244353;
const int N = 1e5+10;
int arr[N];
struct node{
int sum,front,back;
}temp,result;
signed main()
{
int n;cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr[i];temp.sum += arr[i];
if(i==0) result = temp;
if(arr[i]>temp.sum)
{
temp.front = i;
temp.sum = arr[i];
}
if(result.sum<temp.sum)
{
temp.back = i;
result = temp;
}
}
if(result.sum<0) cout<<0<<" "<<arr[0]<<" "<<arr[n-1]<<endl;
else cout<<result.sum<<" "<<arr[result.front]<<" "<<arr[result.back]<<endl;
return 0;
}
边栏推荐
- [internship] solve the problem of too long request parameters
- 有时候只查询一行语句,执行也慢
- NMF-matlab
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
- Detailed upgrade process of AWS eks
- Exemple complet d'enregistrement du modèle pytoch + enregistrement du modèle pytoch seuls les paramètres d'entraînement sont - ils enregistrés? Oui (+ Solution)
- Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of the inverted front fork of the global market in 2022
- 面试经验总结,为你的offer保驾护航,满满的知识点
- 现在券商的优惠开户政策什么?实际上网上开户安全么?
- [NLP] a detailed generative text Abstract classic paper pointer generator
猜你喜欢
I did a craniotomy experiment: talk about macromolecule coding theory and Lao Wang's fallacy from corpus callosum and frontal leukotomy
有时候只查询一行语句,执行也慢
Database schema notes - how to choose the right database in development + who invented relational database?
CRM客户关系管理系统
【QT】QPushButton创建
Talk about macromolecule coding theory and Lao Wang's fallacy from the perspective of evolution theory
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #
The first of the classic quotations of correspondents is heartbreaking
sql-labs
Driverless learning (4): Bayesian filtering
随机推荐
想请教一下,我在东莞,到哪里开户比较好?手机开户是安全么?
GCC: Graph Contrastive Coding for Graph Neural NetworkPre-Training
Driverless learning (4): Bayesian filtering
Taiwan SSS Xinchuang sss1700 replaces cmmedia cm6533 24bit 96KHz USB audio codec chip
For (Auto A: b) and for (Auto & A: b) usage
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of voltage source converters in the global market in 2022
I want to ask you, where is a better place to open an account in Dongguan? Is it safe to open a mobile account?
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of shock absorber oil in the global market in 2022
[JS] get the search parameters of URL in hash mode
c语言链表--待补充
在网上炒股开户安全吗?我是新手,还请指导
B端电商-订单逆向流程
[QT] QPushButton creation
Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)
B-end e-commerce - reverse order process
【Hot100】22. bracket-generating
Google Earth Engine(GEE)——Landsat 9影像全波段影像下载(北京市为例)
Development skills of rxjs observable custom operator
After 65 days of closure and control of the epidemic, my home office experience sharing | community essay solicitation
How to do interface testing? After reading this article, it will be clear