Submission #826800

#TimeUsernameProblemLanguageResultExecution timeMemory
826800devariaotaFeast (NOI19_feast)C++17
30 / 100
32 ms5604 KiB
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<int> a(n); for(int &p : a) cin >> p; if(k==1) { int ans=0, cur=0; for(int p : a) ans=max(ans, cur=max(0LL, cur+p)); cout << ans << '\n'; } else { int ans=0; for(int p : a) { if(p>=0) ans+=p; } cout << ans << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...