Submission #499696

#TimeUsernameProblemLanguageResultExecution timeMemory
499696sireanu_vladBigger segments (IZhO19_segments)C++14
37 / 100
1557 ms2332 KiB
#include <iostream> using namespace std; int n, v[500001], seg[500001], k[500001]; unsigned long long sum[500001]; void read() { cin >> n; for(int i = 1; i <= n; ++i) { cin >> v[i]; sum[i] = sum[i-1] + v[i]; } } int main() { read(); for(int i = 1; i <= n; ++i) for(int j = 0; j < i; ++j) if(sum[i] - sum[j] >= sum[j] - sum[seg[j]]) if(k[i] <= k[j] + 1) { k[i] = k[j] + 1; seg[i] = j; } cout << k[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...