# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90503 | 2018-12-22T03:17:59 Z | daniel_02 | Divide and conquer (IZhO14_divide) | C++14 | 17 ms | 1304 KB |
#include <bits/stdc++.h> #define fr first #define pb push_back #define sc second #define ll long long using namespace std; const int N = 5005; pair<int, pair<int, int>> a[N]; ll pre[N], prg[N], ans; main() { int n; cin >> n; for (int i = 1; i <= n; i++) { scanf("%d%d%d", &a[i].fr, &a[i].sc.fr, &a[i].sc.sc); pre[i] = pre[i - 1] + a[i].sc.sc; prg[i] = prg[i - 1] + a[i].sc.fr; } for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { if (a[j].fr - a[i].fr <= pre[j] - pre[i - 1]) { if (ans < prg[j] - prg[i - 1]) { ans = prg[j] - prg[i - 1]; } } } } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 356 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
3 | Correct | 2 ms | 456 KB | Output is correct |
4 | Correct | 2 ms | 536 KB | Output is correct |
5 | Correct | 2 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 564 KB | Output is correct |
7 | Correct | 2 ms | 568 KB | Output is correct |
8 | Correct | 2 ms | 572 KB | Output is correct |
9 | Correct | 2 ms | 596 KB | Output is correct |
10 | Correct | 2 ms | 596 KB | Output is correct |
11 | Correct | 2 ms | 604 KB | Output is correct |
12 | Correct | 2 ms | 660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 660 KB | Output is correct |
2 | Correct | 2 ms | 664 KB | Output is correct |
3 | Correct | 2 ms | 668 KB | Output is correct |
4 | Correct | 2 ms | 668 KB | Output is correct |
5 | Correct | 3 ms | 752 KB | Output is correct |
6 | Correct | 3 ms | 752 KB | Output is correct |
7 | Correct | 3 ms | 780 KB | Output is correct |
8 | Correct | 3 ms | 800 KB | Output is correct |
9 | Correct | 4 ms | 820 KB | Output is correct |
10 | Correct | 4 ms | 848 KB | Output is correct |
11 | Correct | 17 ms | 1012 KB | Output is correct |
12 | Correct | 17 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 1240 KB | Output is correct |
2 | Execution timed out | 4 ms | 1304 KB | Time limit exceeded (wall clock) |
3 | Halted | 0 ms | 0 KB | - |