d784. 一、連續元素的和 - 高中生程式解題系統
本文最後更新於:2024年1月12日 下午
Zerojudge
解題紀錄
d784. 一、連續元素的和 - 高中生程式解題系統
// Author : ysh
// 06/10/2022 Fri 13:57:58.91
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include<C:\Users\Public\debug.h>
#else
#define debug(...) '*'
#define printf(...) '*'
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string tmp;
int n;getline(cin,tmp);n = stoi(tmp);
debug(n);
while(n--) {
string a;
getline(cin,a);
stringstream s;
s << a;
int b;
vector<int>f;
s >> a;
while(s >> b) {
f.push_back(b);
}
// f.pop_front();
int mmax = f[0];
int len = f.size();
for(int i = 1;i < len;i++) {
f[i] = max(f[i],f[i - 1] + f[i]);
mmax = max(mmax,f[i]);
}
debug(f);
cout<<mmax<<"\n";
}
return 0;
}
d784. 一、連續元素的和 - 高中生程式解題系統
http://mysh212.github.io/algosolution/Zerojudge-d784-3.cpp/