답안 #572850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
572850 2022-06-05T11:40:43 Z denniskim Coins (BOI06_coins) C++17
80 / 100
94 ms 8060 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second

ll n, k;
pair<ll, ll> a[500010];
ll ans1, ans2;

int main(void)
{
	scanf("%lld %lld", &n, &k);
	
	for(ll i = 1 ; i <= n ; i++)
		scanf("%lld %lld", &a[i].fi, &a[i].se);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		if(a[i].se)
			continue;
		
		if(ans1 + a[i].fi < min(a[i + 1].fi, k + 1))
		{
			ans1 += a[i].fi;
			ans2++;
		}
	}
	
	if(!ans1)
		ans1 = 1;
	
	printf("%lld\n%lld", ans2, k - ans1);
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%lld %lld", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
coins.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%lld %lld", &a[i].fi, &a[i].se);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Incorrect 84 ms 8060 KB Output isn't correct
8 Correct 94 ms 8052 KB Output is correct
9 Correct 87 ms 8012 KB Output is correct
10 Correct 86 ms 8036 KB Output is correct