# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167824 | 2019-12-10T09:44:29 Z | juggernaut | Divide and conquer (IZhO14_divide) | C++14 | 50 ms | 1528 KB |
#include<bits/stdc++.h> #define int long long int using namespace std; struct data{ int x,g,d; }; data a[100001]; int n,i,l,r,x,g,mx,d,cnt=1; main(){ scanf("%lld",&n); cin>>a[1].x>>a[1].g>>a[1].d; for(i=2;i<=n;i++) { scanf("%lld%lld%lld",&x,&g,&d); if(a[cnt].x + a[cnt].d >= x){ a[cnt].d+=d; a[cnt].g+=g; } else{ cnt++; a[cnt].x=x; a[cnt].d=d; a[cnt].g=g; } } n=cnt; l=r=1; x=a[1].x; g=a[1].g; d=a[1].d; while(r<=n&&l<=n){ if(r<n&&d+a[r+1].d>=a[r+1].x-x){ r++; d+=a[r].d; g+=a[r].g; mx=max(mx,g); }else{ g-=a[l].g; d-=a[l].d; l++; x=a[l].x; } } l=r=n; x=a[n].x; g=a[n].g; d=a[n].d; while(r>0&&l>0){ if(l>0&&d+a[l-1].d>=x-a[l-1].x){ l--; d+=a[l].d; g+=a[l].g; mx=max(mx,g); }else{ g-=a[r].g; d-=a[r].d; r--; x=a[r].x; } } printf("%lld",mx); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 380 KB | Output is correct |
5 | Correct | 2 ms | 248 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Incorrect | 2 ms | 256 KB | Output isn't correct |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 256 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 6 ms | 348 KB | Output is correct |
4 | Correct | 20 ms | 380 KB | Output is correct |
5 | Correct | 24 ms | 376 KB | Output is correct |
6 | Correct | 50 ms | 376 KB | Output is correct |
7 | Correct | 36 ms | 504 KB | Output is correct |
8 | Correct | 37 ms | 376 KB | Output is correct |
9 | Correct | 34 ms | 368 KB | Output is correct |
10 | Incorrect | 37 ms | 1528 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |