제출 #334014

#제출 시각아이디문제언어결과실행 시간메모리
334014ronnithPod starim krovovima (COCI20_psk)C++14
50 / 50
1 ms364 KiB
#include <bits/stdc++.h>

typedef long long ll;
#define mk make_pair
#define f first
#define s second

using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	ll x;
	pair<ll, ll> z[n];
	ll sm = 0;
	ll sum = 0;
	for(int i = 0;i < n;i ++){
		scanf("%lld%lld", &x, &z[i].f);
		z[i].s = i;
		sm = sm + x;
		sum += z[i].f;
	}
	sort(z, z + n);
	ll cnt = 0;
	ll ans = 0;
	ll an[n];
	for(int i = 0;i < n;i ++){
		cnt += z[i].f;
		if(sum - cnt >= sm){
			ans = i + 1;
		} else break;
	}
	printf("%lld\n", ans);
	for(int i = 0;i < n;i ++){
		if(i < ans)
			an[z[i].s] = 0;
		else {
			int h = min(sm, z[i].f);
			an[z[i].s] = h;
			sm -= h;
		}
	}
	for(int i = 0;i < n;i ++){
		printf("%lld ", an[i]);
	}
	puts("");
	return 0;
}

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

psk.cpp: In function 'int main()':
psk.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
psk.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%lld%lld", &x, &z[i].f);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...