# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
68513 | 2018-08-17T08:44:48 Z | ege_eksi | Divide and conquer (IZhO14_divide) | C++14 | 1000 ms | 2032 KB |
#include<iostream> #include<cstdio> #include<cstdlib> #include<climits> using namespace std; int x[100000]; int g[100000]; int e[100000]; long long int prefix_g[100000]; long long int prefix_e[100000]; int main() { int n; scanf("%d",&n); for(int i = 0 ; i < n ; i++) { scanf("%d %d %d",&x[i] , &g[i] , &e[i]); } prefix_g[0] = g[0]; prefix_e[0] = e[0]; for(int i = 1 ; i < n ; i++) { prefix_g[i] = prefix_g[i-1] + g[i]; prefix_e[i] = prefix_e[i-1] + e[i]; } long long int total_e; long long int total_dist; long long int total_gold; long long int ans = 0; for(int i = 0 ; i < n ; i++) { for(int j = i ; j < n ; j++) { if(i == 0) { total_e = prefix_e[j]; total_gold = prefix_g[j]; } else { total_e = prefix_e[j] - prefix_e[i-1]; total_gold = prefix_g[j] - prefix_g[i-1]; } total_dist = x[j] - x[i]; if(total_e >= total_dist) { ans = max(ans , total_gold); } } } printf("%lli",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 452 KB | Output is correct |
3 | Correct | 3 ms | 452 KB | Output is correct |
4 | Correct | 2 ms | 452 KB | Output is correct |
5 | Correct | 2 ms | 452 KB | Output is correct |
6 | Correct | 3 ms | 500 KB | Output is correct |
7 | Correct | 2 ms | 544 KB | Output is correct |
8 | Correct | 2 ms | 544 KB | Output is correct |
9 | Correct | 2 ms | 544 KB | Output is correct |
10 | Correct | 3 ms | 544 KB | Output is correct |
11 | Correct | 3 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 592 KB | Output is correct |
2 | Correct | 2 ms | 592 KB | Output is correct |
3 | Correct | 4 ms | 592 KB | Output is correct |
4 | Correct | 4 ms | 620 KB | Output is correct |
5 | Correct | 4 ms | 648 KB | Output is correct |
6 | Correct | 6 ms | 648 KB | Output is correct |
7 | Correct | 4 ms | 648 KB | Output is correct |
8 | Correct | 5 ms | 704 KB | Output is correct |
9 | Correct | 6 ms | 704 KB | Output is correct |
10 | Correct | 9 ms | 704 KB | Output is correct |
11 | Correct | 27 ms | 704 KB | Output is correct |
12 | Correct | 32 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 28 ms | 876 KB | Output is correct |
2 | Correct | 108 ms | 1004 KB | Output is correct |
3 | Correct | 103 ms | 1004 KB | Output is correct |
4 | Execution timed out | 1081 ms | 2032 KB | Time limit exceeded |
5 | Halted | 0 ms | 0 KB | - |