답안 #137577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137577 2019-07-28T06:52:45 Z 송준혁(#3282) Coins (BOI06_coins) C++14
90 / 100
135 ms 5184 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int N, K;
vector<int> P;

int main(){
	scanf("%d %d", &N, &K);
	P.push_back(0);
	int x, y, t;
	scanf("%d %d", &x, &t);
	for (int i=2; i<=N; i++){
		scanf("%d", &y);
		if (!t){
			int k = upper_bound(P.begin(), P.end(), y-x-1) - P.begin() - 1;
			if (k+1 >= P.size()) P.push_back(x + P[k]);
		}
		x = y;
		scanf("%d", &t);
	}
	if (!t) P.push_back(x + *(--P.end()));
	int k = upper_bound(P.begin(), P.end(), K-1) - P.begin() - 1;
	printf("%d\n%d\n", k, K-P[k]);
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:18:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if (k+1 >= P.size()) P.push_back(x + P[k]);
        ~~~~^~~~~~~~~~~
coins.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &N, &K);
  ~~~~~^~~~~~~~~~~~~~~~~
coins.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &x, &t);
  ~~~~~^~~~~~~~~~~~~~~~~
coins.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &y);
   ~~~~~^~~~~~~~~~
coins.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &t);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 119 ms 5112 KB Output is correct
8 Incorrect 116 ms 5184 KB Output isn't correct
9 Correct 135 ms 5112 KB Output is correct
10 Correct 132 ms 5112 KB Output is correct