답안 #80964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
80964 2018-10-23T09:59:32 Z farukkastamonuda 금 캐기 (IZhO14_divide) C++14
48 / 100
1000 ms 18332 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 = son - 1;
		}
		cev = max(cev, sumg[son] - 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]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 2 ms 692 KB Output is correct
4 Correct 2 ms 816 KB Output is correct
5 Correct 3 ms 816 KB Output is correct
6 Correct 2 ms 816 KB Output is correct
7 Correct 2 ms 816 KB Output is correct
8 Correct 2 ms 816 KB Output is correct
9 Correct 2 ms 816 KB Output is correct
10 Correct 2 ms 816 KB Output is correct
11 Correct 2 ms 832 KB Output is correct
12 Correct 2 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 984 KB Output is correct
2 Correct 2 ms 996 KB Output is correct
3 Correct 2 ms 996 KB Output is correct
4 Correct 3 ms 1008 KB Output is correct
5 Correct 3 ms 1040 KB Output is correct
6 Correct 3 ms 1084 KB Output is correct
7 Correct 3 ms 1136 KB Output is correct
8 Correct 2 ms 1176 KB Output is correct
9 Correct 4 ms 1192 KB Output is correct
10 Correct 6 ms 1220 KB Output is correct
11 Correct 25 ms 1640 KB Output is correct
12 Correct 25 ms 1668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1808 KB Output is correct
2 Correct 18 ms 2128 KB Output is correct
3 Correct 7 ms 2256 KB Output is correct
4 Correct 27 ms 4868 KB Output is correct
5 Correct 30 ms 6200 KB Output is correct
6 Correct 63 ms 11296 KB Output is correct
7 Correct 46 ms 12980 KB Output is correct
8 Correct 46 ms 14936 KB Output is correct
9 Correct 45 ms 16664 KB Output is correct
10 Execution timed out 1078 ms 18332 KB Time limit exceeded
11 Halted 0 ms 0 KB -