Submission #80998

# Submission time Handle Problem Language Result Execution time Memory
80998 2018-10-23T11:51:01 Z farukkastamonuda Divide and conquer (IZhO14_divide) C++14
17 / 100
76 ms 4476 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;
lo int x[li], g[li], d[li], sume[li], sumg[li], cev;
bool check(int val, int beg){
	if(x[val] - x[beg] <= sume[val] - sume[beg - 1]) return true;
	return false;
}
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld %lld %lld", &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;
			if(check(mid, i)) bas = mid + 1;
			else son = mid - 1;
		}
		int bio = max(0, son - 1);
		int bioo = max(0, son - 2);
		bio = min(bio , n);
		bioo = min(bioo, n);
		int bis = min(n, son + 1);
		int biss = min(n, son + 2);
		int orta = max(0, son);
		orta = min(orta, n);
		if(bio >= i && check(bio, i)) cev = max(cev, sumg[bio] - sumg[i - 1]);
		if(bis >= i && check(bis, i)) cev = max(cev, sumg[bis] - sumg[i - 1]);
		if(orta >= i && check(orta, i)) cev = max(cev, sumg[orta] - sumg[i - 1]);
		if(bioo >= i && check(bioo, i)) cev = max(cev, sumg[bioo] - sumg[i - 1]);
		if(biss >= i && check(biss, i)) cev = max(cev, sumg[biss] - sumg[i - 1]);
	}
	printf("%lld\n", cev);
	return 0;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
divide.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &x[i], &g[i], &d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 500 KB Output is correct
6 Correct 2 ms 500 KB Output is correct
7 Correct 2 ms 500 KB Output is correct
8 Correct 2 ms 500 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 2 ms 500 KB Output is correct
11 Correct 2 ms 612 KB Output is correct
12 Correct 2 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 612 KB Output is correct
2 Correct 2 ms 612 KB Output is correct
3 Incorrect 3 ms 612 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 712 KB Output is correct
2 Correct 6 ms 900 KB Output is correct
3 Correct 7 ms 916 KB Output is correct
4 Correct 40 ms 2576 KB Output is correct
5 Correct 29 ms 2576 KB Output is correct
6 Correct 63 ms 4388 KB Output is correct
7 Correct 48 ms 4388 KB Output is correct
8 Correct 51 ms 4452 KB Output is correct
9 Correct 43 ms 4452 KB Output is correct
10 Incorrect 76 ms 4476 KB Output isn't correct
11 Halted 0 ms 0 KB -