답안 #137548

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
137548 2019-07-28T06:24:50 Z 김세빈(#3278) Coins (BOI06_coins) C++14
90 / 100
134 ms 4344 KB
#include <bits/stdc++.h>

using namespace std;

int C[505050], D[505050];
vector <int> V;
int n, k, s, v;

int main()
{
	int i, r, t;
	
	scanf("%d%d", &n, &k);
	
	for(i=1; i<=n; i++){
		scanf("%d%d", C + i, D + i);
		if(C[i] > k) break;
	}
	
	n = i;
	C[n] = k + 1; D[n] = 1;
	
	V.push_back(0); s = 0;
	
	for(i=1; i<n; i++){
		if(C[i] + C[i] <= C[i + 1]) r = C[i] - 1;
		else r = (C[i + 1] - 1) % C[i];
		if(!D[i] && r >= V[s]){
			V.push_back(V[s] + C[i]); s ++;
		}
	}
	
	printf("%d\n%d\n", s, k - V[s]);
	
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:11:12: warning: unused variable 't' [-Wunused-variable]
  int i, r, t;
            ^
coins.cpp:13: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:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", C + i, D + i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 117 ms 4296 KB Output is correct
8 Incorrect 115 ms 4344 KB Output isn't correct
9 Correct 134 ms 4188 KB Output is correct
10 Correct 122 ms 4216 KB Output is correct