답안 #1017181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017181 2024-07-09T05:40:55 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
40 / 50
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	int x,y,su=0;
	vector<pair<int,int>> cap;
	for (int i=0;i<n;i++)
	{
		cin>>x>>y;
		su+=x;
		cap.push_back({y,i});
	}
	sort(rbegin(cap),rend(cap));
	int ans=0,a[n]={};
	if (!su)
		ans=n;
	else
	{
		for (int i=0;i<n;i++)
		{
			a[cap[i].second]=min(cap[i].first,su);
			su-=a[cap[i].second];
			if (!su)
			{
				ans=n-i-1;
				break;
			}
		}
	}
	cout<<ans<<endl;
	for (int i=0;i<n;i++)
		cout<<a[i]<<' ';
	cout<<endl;
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct