Submission #90999

# Submission time Handle Problem Language Result Execution time Memory
90999 2018-12-25T13:58:44 Z Nodir_Bobiev Divide and conquer (IZhO14_divide) C++14
0 / 100
40 ms 16720 KB
# include <bits/stdc++.h>

# define ll long long
# define fi first
# define se second

using namespace std;

const ll  INF = 8e18 + 10;
const ll  MOD = 1e9 + 7;
const int N = 1e5 + 10;
const int Z = 5e4 + 10;

ll n;
ll x[N], g[N], e[N], pf[N], ans;

void solve()
{
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> x[i] >> g[i] >> e[i];
		g[i] += g[i - 1];
		e[i] += e[i - 1];
		pf[i] = min(pf[i - 1], e[i] - x[i]);
		//cout << pf[i] << ' ';
	}
	
	for (int i = 1; i <= n; i++){
		int l = 1, m, r = i;
		ans = max(ans, g[i] - g[i - 1]);
		
		while(r >= l){
			m = (l + r) >> 1;
			
			if(pf[m] <= e[i] - x[i]){
				ans = max(ans, g[i] - g[m - 1]);
				r = m - 1;
			}
			else 
				l = m + 1;
		}
	}
	cout << ans;
}


int main()
{
	int TE = 1;
	ios_base::sync_with_stdio(false);
	//freopen("sort.in", "r", stdin);
	//freopen("sort.out", "w", stdout);
	//cin >> TE;
	
	while(TE --)
		solve();
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Incorrect 2 ms 592 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 720 KB Output is correct
2 Correct 4 ms 1040 KB Output is correct
3 Correct 5 ms 1284 KB Output is correct
4 Correct 28 ms 3576 KB Output is correct
5 Correct 20 ms 4876 KB Output is correct
6 Correct 40 ms 9400 KB Output is correct
7 Correct 33 ms 11300 KB Output is correct
8 Correct 33 ms 13324 KB Output is correct
9 Correct 32 ms 14868 KB Output is correct
10 Incorrect 32 ms 16720 KB Output isn't correct
11 Halted 0 ms 0 KB -