Submission #482851

#TimeUsernameProblemLanguageResultExecution timeMemory
482851levsog2004Bigger segments (IZhO19_segments)C++14
0 / 100
0 ms204 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, a[N],ans[N],idx[N]; int main() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; a[i] += a[i - 1]; } for (int i = 1; i <= n; ++i) { idx[i] = max(idx[i], idx[i - 1]); ans[i] = ans[idx[i]] + 1; int id = lower_bound(a + 1, a + n + 1, 2 * a[i] - a[idx[i]]) - a; if (id <= n) idx[id] = max(idx[id],ll(i)); } 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...