Submission #318731

# Submission time Handle Problem Language Result Execution time Memory
318731 2020-11-03T03:44:03 Z Gurban Divide and conquer (IZhO14_divide) C++17
100 / 100
54 ms 6884 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int maxn=1e5+5;
int n,x,g,e;
ll p[maxn],T[4*maxn],jog[maxn],ans;

void upd(int pos,ll val,int l,int r,int nd){
	if(l == r){
		T[nd]=val;
		return;
	}
	if(pos <= (l+r)/2) upd(pos,val,l,(l+r)/2,nd*2);
	else upd(pos,val,(l+r)/2+1,r,nd*2+1);
	T[nd] = max(T[nd*2],T[nd*2+1]);
}

int tap(ll val,int l,int r,int nd){
	if(l==r) return l;
	if(T[nd*2] >= val) return tap(val,l,(l+r)/2,nd*2);
	return tap(val,(l+r)/2+1,r,nd*2+1);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> x >> g >> e;
		p[i]=p[i-1]+e;
		jog[i]=jog[i-1]+g;
		upd(i,x - p[i-1],1,n,1);
		int pos=tap(x-p[i],1,n,1);
		ans = max(ans,jog[i]-jog[pos-1]);
	}
	cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 3 ms 620 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 3 ms 620 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
25 Correct 3 ms 624 KB Output is correct
26 Correct 4 ms 876 KB Output is correct
27 Correct 6 ms 1004 KB Output is correct
28 Correct 29 ms 3168 KB Output is correct
29 Correct 26 ms 3456 KB Output is correct
30 Correct 54 ms 6884 KB Output is correct
31 Correct 46 ms 5736 KB Output is correct
32 Correct 49 ms 5860 KB Output is correct
33 Correct 48 ms 5600 KB Output is correct
34 Correct 48 ms 5604 KB Output is correct
35 Correct 51 ms 6116 KB Output is correct
36 Correct 52 ms 6244 KB Output is correct