当前位置:网站首页>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;
}边栏推荐
- Automatic reading of simple books
- 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)
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度與顯存記錄錶(後續不斷補充)
- The metamask method is used to obtain account information
- 【Hot100】21. 合并两个有序链表
- AMD's largest transaction ever, the successful acquisition of Xilinx with us $35billion
- 攻防世界pwn题:Recho
- Research Report on the overall scale, major manufacturers, major regions, products and applications of friction dampers in the global market in 2022
- 功能、作用、效能、功用、效用、功效
- Jetson XAVIER NX上ResUnet-TensorRT8.2速度与显存记录表(后续不断补充)
猜你喜欢

Properties of expectation and variance

c语言链表--待补充

Postman interface test practice, these five questions you must know

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

【NLP】一文详解生成式文本摘要经典论文Pointer-Generator

upload-labs

How can testers do without missing tests? Seven o'clock is enough

Sometimes only one line of statements are queried, and the execution is slow

Talk about macromolecule coding theory and Lao Wang's fallacy from the perspective of evolution theory

Solution to blue screen after installing TIA botu V17 in notebook
随机推荐
CRM Customer Relationship Management System
为什么我对流程情有独钟?
Is it safe to open an account for online stock speculation? I'm a novice, please guide me
Wu Enda's machine learning mind mapping insists on clocking in for 23 days - building a knowledge context, reviewing, summarizing and replying
C language linked list -- to be added
An analysis of the past and present life of the meta universe
I did a craniotomy experiment: talk about macromolecule coding theory and Lao Wang's fallacy from corpus callosum and frontal leukotomy
Review of the latest 2022 research on "deep learning methods for industrial defect detection"
Taiwan SSS Xinchuang sss1700 replaces cmmedia cm6533 24bit 96KHz USB audio codec chip
Summary of interview experience, escort your offer, full of knowledge points
at编译环境搭建-win
Database schema notes - how to choose the right database in development + who invented relational database?
Automated video production
在网上炒股开户安全吗?我是新手,还请指导
Google Earth engine (GEE) - Landsat 9 image full band image download (Beijing as an example)
pytorch 模型保存的完整例子+pytorch 模型保存只保存可训练参数吗?是(+解决方案)
burp 安装 license key not recognized
在券商账户上买基金安全吗?哪里可以买基金
Solution to blue screen after installing TIA botu V17 in notebook
Redis sentinel cluster working principle and architecture deployment # yyds dry goods inventory #