답안 #172675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172675 2020-01-02T10:45:21 Z tselmegkh 금 캐기 (IZhO14_divide) C++14
0 / 100
1000 ms 2652 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int x[N], g[N], d[N];
int main(){
	int n;
	cin >> n;

	long long curenergy = 0, curgold = 0;
	for(int i = 1; i <= n; i++){
		cin >> x[i] >> g[i] >> d[i];
		curgold += g[i];
		curenergy += d[i];	
	}
	int l = 1, r = n;

	while(x[r] - x[l] > curenergy){
		if(r - l == 1){
			if(g[r] > g[l]){
				curgold -= g[l];
				curenergy -= d[l];
				l++;
			}else{
				curgold -= g[r];
				curenergy -= d[r];
				r--;
			}
		}else{
			if(curenergy - d[l] >= x[r] - x[l + 1] && curenergy - d[r] >= x[r - 1] - x[l]){
				if(g[r] > g[l]){
					curgold -= g[l];
					curenergy -= d[l];
					l++;
				}else{
					curgold -= g[r];
					curenergy -= d[r];
					r--;
				}
			}else if(curenergy - d[l] >= x[r] - x[l + 1]){
				curgold -= g[l];
				curenergy -= d[l];
				l++;
			}else if(curenergy - d[r] >= x[r - 1] - x[l]){
				curgold -= g[r];
				curenergy -= d[r];
				r--;
			}
		}
	}
	cout << curgold << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Execution timed out 1076 ms 376 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Execution timed out 1045 ms 296 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 376 KB Output is correct
2 Correct 14 ms 572 KB Output is correct
3 Correct 18 ms 632 KB Output is correct
4 Correct 87 ms 1912 KB Output is correct
5 Correct 102 ms 2064 KB Output is correct
6 Correct 231 ms 2652 KB Output is correct
7 Correct 150 ms 2644 KB Output is correct
8 Correct 150 ms 2568 KB Output is correct
9 Correct 144 ms 2596 KB Output is correct
10 Execution timed out 1020 ms 2628 KB Time limit exceeded
11 Halted 0 ms 0 KB -