# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520563 | 2022-01-30T09:12:09 Z | krit3379 | Divide and conquer (IZhO14_divide) | C++17 | 40 ms | 6500 KB |
#include<bits/stdc++.h> using namespace std; #define N 100005 using pii = pair<long long,long long>; long long x[N],g[N],p[N],ans; deque<pii> dq; int main(){ int n,i; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%lld %lld %lld",&x[i],&g[i],&p[i]); ans=max(ans,g[i]); g[i]+=g[i-1]; p[i]+=p[i-1]; } for(i=n;i>0;i--){ auto it=lower_bound(dq.begin(),dq.end(),(pii){p[i-1]-x[i],-1}); if(it!=dq.end())ans=max(ans,(*it).second-g[i-1]); if(dq.empty()||p[i]-x[i]>dq.back().first)dq.push_back({p[i]-x[i],g[i]}); } printf("%lld",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 0 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 312 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 2 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 316 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 552 KB | Output is correct |
24 | Correct | 2 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 0 ms | 204 KB | Output is correct |
10 | Correct | 0 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 204 KB | Output is correct |
13 | Correct | 0 ms | 208 KB | Output is correct |
14 | Correct | 1 ms | 204 KB | Output is correct |
15 | Correct | 1 ms | 204 KB | Output is correct |
16 | Correct | 1 ms | 312 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 2 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 316 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 2 ms | 552 KB | Output is correct |
24 | Correct | 2 ms | 588 KB | Output is correct |
25 | Correct | 2 ms | 460 KB | Output is correct |
26 | Correct | 3 ms | 588 KB | Output is correct |
27 | Correct | 5 ms | 716 KB | Output is correct |
28 | Correct | 14 ms | 2348 KB | Output is correct |
29 | Correct | 17 ms | 2768 KB | Output is correct |
30 | Correct | 40 ms | 5464 KB | Output is correct |
31 | Correct | 40 ms | 4352 KB | Output is correct |
32 | Correct | 28 ms | 4364 KB | Output is correct |
33 | Correct | 27 ms | 4132 KB | Output is correct |
34 | Correct | 35 ms | 4960 KB | Output is correct |
35 | Correct | 33 ms | 6288 KB | Output is correct |
36 | Correct | 35 ms | 6500 KB | Output is correct |