当前位置:网站首页>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;
}边栏推荐
- 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
- Use graalvm native image to quickly expose jar code as a native shared library
- Interested parties add me for private chat
- The first of the classic quotations of correspondents is heartbreaking
- Google Earth engine (GEE) - Landsat 9 image full band image download (Beijing as an example)
- AcWing 341. Optimal trade solution (shortest path, DP)
- Research and Analysis on the current situation of China's clamping device market and forecast report on its development prospect
- [译]深入了解现代web浏览器(一)
- Workplace four quadrant rule: time management four quadrant and workplace communication four quadrant "suggestions collection"
- Research Report on the overall scale, major manufacturers, major regions, products and applications of micro hydraulic cylinders in the global market in 2022
猜你喜欢

c语言链表--待补充

为什么我对流程情有独钟?

Activation function - relu vs sigmoid

Complete example of pytorch model saving +does pytorch model saving only save trainable parameters? Yes (+ solution)
![[daily question] 241 Design priorities for operational expressions](/img/27/4ad1a557e308e4383335f51a51adb0.png)
[daily question] 241 Design priorities for operational expressions

「 工业缺陷检测深度学习方法」最新2022研究综述
![[QT] QPushButton creation](/img/c4/bc0c346e394484354e5b9d645916c0.png)
[QT] QPushButton creation

Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)

勵志!大凉山小夥全獎直博!論文致謝看哭網友

How to realize the function of detecting browser type in Web System
随机推荐
【Hot100】22. bracket-generating
How to open an account online? Is it safe to open a mobile account?
I did a craniotomy experiment: talk about macromolecule coding theory and Lao Wang's fallacy from corpus callosum and frontal leukotomy
Use graalvm native image to quickly expose jar code as a native shared library
Automated video production
Cs5268 perfectly replaces ag9321mcq typec multi in one docking station solution
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #
想问问,现在开户有优惠吗?在线开户是安全么?
Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)
数据库模式笔记 --- 如何在开发中选择合适的数据库+关系型数据库是谁发明的?
What is online account opening? Is it safe to open an account online now?
[cloud native topic -50]:kubesphere cloud Governance - operation - step by step deployment of microservice based business applications - database middleware MySQL microservice deployment process
CheckListBox control usage summary
Research Report on the overall scale, major manufacturers, major regions, products and applications of capacitive voltage transformers in the global market in 2022
AcWing 340. Solution to communication line problem (binary + double ended queue BFS for the shortest circuit)
How my mother-in-law and daughter-in-law get along
Research Report on the overall scale, major manufacturers, major regions, products and applications of outdoor vacuum circuit breakers in the global market in 2022
How to do interface testing? After reading this article, it will be clear
Cron expression (seven subexpressions)
面试经验总结,为你的offer保驾护航,满满的知识点