답안 #172679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172679 2020-01-02T10:48:35 Z tselmegkh 금 캐기 (IZhO14_divide) C++14
0 / 100
220 ms 1784 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--;
			}else{
				curgold -= g[l];
				curgold -= g[r];
				curenergy -= d[l];
				curenergy -= d[r];
				l++;
				r--;
			}
		}
	}
	cout << curgold << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
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 Incorrect 3 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 504 KB Output is correct
2 Correct 13 ms 604 KB Output is correct
3 Correct 18 ms 604 KB Output is correct
4 Correct 90 ms 1036 KB Output is correct
5 Correct 102 ms 1144 KB Output is correct
6 Correct 220 ms 1700 KB Output is correct
7 Correct 150 ms 1784 KB Output is correct
8 Correct 156 ms 1660 KB Output is correct
9 Correct 144 ms 1756 KB Output is correct
10 Incorrect 143 ms 1656 KB Output isn't correct
11 Halted 0 ms 0 KB -