Submission #950556

#TimeUsernameProblemLanguageResultExecution timeMemory
950556VMaksimoski008Feast (NOI19_feast)C++14
18 / 100
93 ms4552 KiB
#include <bits/stdc++.h> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; const double eps = 1e-9; int32_t main() { int n, k, neg = 0; cin >> n >> k; vector<int> v(n+1); for(int i=1; i<=n; i++) cin >> v[i], neg += (v[i] < 0); if(k == 1) { ll ans = 0, sum = 0, mn = 0; for(int i=1; i<=n; i++) { sum += v[i]; ans = max(ans, sum - mn); mn = min(mn, sum); } cout << ans << '\n'; return 0; } 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...