제출 #151393

#제출 시각아이디문제언어결과실행 시간메모리
151393gs14004Coins (BOI06_coins)C++17
90 / 100
121 ms10104 KiB
#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 + 1;
	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;
}

컴파일 시 표준 에러 (stderr) 메시지

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);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...