답안 #151394

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151394 2019-09-02T15:50:28 Z gs14004 Coins (BOI06_coins) C++17
90 / 100
119 ms 4280 KB
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int main(){
	int n, k; scanf("%d %d",&n,&k);
	vector<pi> v(n + 1);
	for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
	v[n].first = k;
	int sum = 0, cnt = 0;
	for(int i=0; i<n; i++){
		if(!v[i].second && sum + v[i].first < v[i+1].first){
			sum += v[i].first;
			cnt++;
		}
	}
	cout << cnt << endl << k - sum << endl;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, k; scanf("%d %d",&n,&k);
            ~~~~~^~~~~~~~~~~~~~~
coins.cpp:10:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 108 ms 4216 KB Output is correct
8 Incorrect 107 ms 4280 KB Output isn't correct
9 Correct 119 ms 4216 KB Output is correct
10 Correct 119 ms 4276 KB Output is correct