Submission #482845

#TimeUsernameProblemLanguageResultExecution timeMemory
482845levsog2004Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms300 KiB
#include <iostream> #include <iomanip> #include <fstream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <queue> #include <deque> #include <stack> #include <cmath> #include <list> #include <set> #include <map> using namespace std; #define all(a) a.begin(), a.end() typedef long long ll; const ll N = 2000004; const ll mod = 1000 * 1000 * 1000 + 7; const ll inf = 1000000000; ll n, m, k, z, t, x, y, ans,a[N]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; } x = a[0]; ans = 1; for (int i = 1; i < n;) { int j = i; y = 0; while (i<n && y < x) { y += a[i]; ++i; } if (i >= n && y<x) { break; } ans++; while (x + a[j] < y - a[j]) { y -= a[j]; x += a[j]; j++; } x = y; } cout << ans << endl; 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...