Submission #80968

# Submission time Handle Problem Language Result Execution time Memory
80968 2018-10-23T10:15:28 Z farukkastamonuda Divide and conquer (IZhO14_divide) C++17
48 / 100
1000 ms 4644 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000000
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
int n,beg;
lo int x[li], g[li], d[li];
lo int cev, sume[li], sumg[li];
bool check(int val){
	if(x[val] - x[beg] <= sume[val] - sume[beg - 1]) return true;
	return false;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//scanf("%d", &n);
	cin>>n;
	for(int i = 1; i <= n; i ++){
		//scanf("%lld %lld %lld", &x[i], &g[i], &d[i]);
		cin>>x[i]>>g[i]>>d[i];
		sume[i] = sume[i - 1] + d[i];
		sumg[i] = sumg[i - 1] + g[i]; 
	}
	for(int i = 1; i <= n; i ++){
		int bas = i, son = n;
		while(bas <= son){
			int mid = (bas + son) / 2;
			beg = i;
			if(check(mid)) bas = mid + 1;
			else son = son - 1;
		}
		cev = max(cev, sumg[son] - sumg[i - 1]);
	}
	//printf("%lld\n", cev);
	cout<<cev<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 3 ms 488 KB Output is correct
6 Correct 2 ms 488 KB Output is correct
7 Correct 2 ms 516 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 720 KB Output is correct
2 Correct 2 ms 720 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 4 ms 720 KB Output is correct
5 Correct 3 ms 720 KB Output is correct
6 Correct 3 ms 720 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
8 Correct 2 ms 720 KB Output is correct
9 Correct 5 ms 720 KB Output is correct
10 Correct 6 ms 720 KB Output is correct
11 Correct 23 ms 764 KB Output is correct
12 Correct 25 ms 764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 764 KB Output is correct
2 Correct 5 ms 1020 KB Output is correct
3 Correct 5 ms 1020 KB Output is correct
4 Correct 21 ms 2556 KB Output is correct
5 Correct 24 ms 2556 KB Output is correct
6 Correct 56 ms 4476 KB Output is correct
7 Correct 47 ms 4476 KB Output is correct
8 Correct 38 ms 4480 KB Output is correct
9 Correct 36 ms 4480 KB Output is correct
10 Execution timed out 1080 ms 4644 KB Time limit exceeded
11 Halted 0 ms 0 KB -