Submission #167789

# Submission time Handle Problem Language Result Execution time Memory
167789 2019-12-10T06:36:59 Z Gurban Divide and conquer (IZhO14_divide) C++11
0 / 100
301 ms 14412 KB
#include <bits/stdc++.h>

#define pb push_back
#define ss second
#define ff first
#define N 100005
#define inf 1000000009
#define ll long long
#define mid(a,b) (a+b)/2

using namespace std;

int n,pos;
ll T[4 * N][5],x,g,e,go[N],mx;

void upd(ll val,int a,int b,int l,int r,int nd){
	T[nd][0] += T[nd / 2][1];
	T[nd][1] += T[nd / 2][1];
	if(l >= a and r <= b){
		T[nd][0] += val;
		T[nd][1] += val;
		return;
	}
	if(l > b or r < a)
		return;
	upd(val,a,b,l,mid(l,r),nd * 2);
	upd(val,a,b,mid(l,r) + 1,r,nd * 2 + 1);
	T[nd][1] = 0;
	T[nd][0] = max(T[nd * 2][0],T[nd * 2 + 1][0]);
}
int tap(ll x,int l,int r,int nd){
	if(l == r)
		return l;
	T[nd * 2][0] += T[nd][1];
	T[nd * 2][1] += T[nd][1];
	T[nd * 2 + 1][0] += T[nd][1];
	T[nd * 2 + 1][1] += T[nd][1];
	T[nd][1] = 0;
	if(T[nd * 2][0] >= x)
		return tap(x,l,mid(l,r),nd * 2);
	return tap(x,mid(l,r) + 1,r,nd * 2 + 1);
}

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> x >> g >> e;
		go[i] = go[i - 1] + g;
		upd(e,1,i - 1,1,n,1);
		pos = tap(x,1,n,1);
		upd(x+e,i,i,1,n,1);
		mx = max(go[i] - go[pos - 1],mx);
	}	
	cout << mx;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 3 ms 372 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1144 KB Output is correct
2 Correct 20 ms 1656 KB Output is correct
3 Correct 24 ms 1912 KB Output is correct
4 Correct 124 ms 6884 KB Output is correct
5 Correct 140 ms 6980 KB Output is correct
6 Correct 301 ms 14412 KB Output is correct
7 Correct 232 ms 12652 KB Output is correct
8 Correct 239 ms 12920 KB Output is correct
9 Correct 226 ms 12920 KB Output is correct
10 Incorrect 225 ms 13176 KB Output isn't correct
11 Halted 0 ms 0 KB -