답안 #844415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844415 2023-09-05T13:03:15 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
32 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(aa) aa.begin(), aa.end()

int main(){
	int n;
	cin>>n;

	vector<int> ans(n);
	vector<pair<int, int>> v(n);
	int s=0;
	for(int i=0; i<n; i++){
		int a;
		cin>>a>>v[i].first;
		v[i].second=i;

		s+=a;
	}
	sort(all(v), greater<pair<int, int>>());

	int i;
	for(i=0; i<n; i++){
		if(s>=v[i].first){
			ans[v[i].second]=v[i].first;
			s-=v[i].first;
		}
		else{
			ans[i]=s;
			break;
		}
	}
	cout<<n-i-1+(s==0)<<endl;
	for(int j=0; j<n; j++) cout<<ans[j]<<' ';
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB Output is partially correct
2 Partially correct 0 ms 348 KB Output is partially correct
3 Partially correct 0 ms 348 KB Output is partially correct
4 Partially correct 0 ms 348 KB Output is partially correct
5 Partially correct 1 ms 348 KB Output is partially correct
6 Partially correct 0 ms 348 KB Output is partially correct
7 Partially correct 0 ms 348 KB Output is partially correct
8 Partially correct 1 ms 348 KB Output is partially correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Incorrect 1 ms 348 KB Output isn't correct