답안 #556678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556678 2022-05-03T15:13:54 Z sidon Coins (BOI06_coins) C++17
100 / 100
83 ms 8524 KB
#include <bits/stdc++.h>
using namespace std;

const int Z = 5e5 + 1;

int N, K, c[Z], ans, sum;
bool d[Z];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> K;

	for(int i = 0; i < N; ++i)
		cin >> c[i] >> d[i];
	c[N] = K;

	for(int i = 0; i < N; ++i) {
		if(!d[i] && c[i] > sum && c[i] + sum < c[i+1]) {
			sum += c[i];
			ans += 1;
		}
	}
	if(!ans) sum = 1;
	cout << ans << '\n' << K - sum;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 76 ms 8388 KB Output is correct
8 Correct 79 ms 8400 KB Output is correct
9 Correct 83 ms 8524 KB Output is correct
10 Correct 81 ms 8248 KB Output is correct