Submission #372489

# Submission time Handle Problem Language Result Execution time Memory
372489 2021-02-28T12:23:18 Z mariowong Divide and conquer (IZhO14_divide) C++14
100 / 100
43 ms 8172 KB
#include <bits/stdc++.h>
using namespace std;

long long mn,n,m,pt,ans;
pair<long long,long long> f[100005];
long long d[100005],a[100005],e[100005],ps[100005],ttl[100005];
long long l,r,mid;
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> d[i] >> a[i] >> e[i];
		ps[i]=ps[i-1]+e[i];
		ttl[i]=ttl[i-1]+a[i];
	}
	mn=1e18;
	for (int i=n;i>=1;i--){
		if (d[i]-ps[i] < mn){
			mn=d[i]-ps[i];
			pt++; f[pt]=make_pair(d[i]-ps[i],i);
		}
		l=1; r=pt;
		while (l < r){
			mid=(l+r)/2;
			if (f[mid].first <= d[i]-ps[i-1])
			r=mid;
			else
			l=mid+1;
		} 
		ans=max(ans,ttl[f[l].second]-ttl[i-1]);
	} 
	cout << ans << "\n";
	return 0;
}	
# 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 1 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 1 ms 384 KB Output is correct
9 Correct 1 ms 380 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 1 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 1 ms 384 KB Output is correct
9 Correct 1 ms 380 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 364 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 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 4 ms 748 KB Output is correct
24 Correct 3 ms 748 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 1 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 1 ms 384 KB Output is correct
9 Correct 1 ms 380 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 364 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 492 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 492 KB Output is correct
20 Correct 1 ms 492 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 2 ms 492 KB Output is correct
23 Correct 4 ms 748 KB Output is correct
24 Correct 3 ms 748 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 3 ms 876 KB Output is correct
27 Correct 5 ms 1004 KB Output is correct
28 Correct 18 ms 3308 KB Output is correct
29 Correct 19 ms 3692 KB Output is correct
30 Correct 39 ms 7152 KB Output is correct
31 Correct 33 ms 6124 KB Output is correct
32 Correct 34 ms 6124 KB Output is correct
33 Correct 33 ms 5868 KB Output is correct
34 Correct 34 ms 6636 KB Output is correct
35 Correct 41 ms 7916 KB Output is correct
36 Correct 43 ms 8172 KB Output is correct