Submission #1017185

# Submission time Handle Problem Language Result Execution time Memory
1017185 2024-07-09T05:44:13 Z vjudge1 Pod starim krovovima (COCI20_psk) C++17
50 / 50
1 ms 432 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
int const N=2e5+5;
int const mod=1e9+7;


signed main(){
	int n;
	cin>>n;
	vector<pair<int,int>> gla;
	int li=0;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin>>a;
		li+=a;
		cin>>a;
		gla.push_back({a,i});
	}
	sort(gla.begin(), gla.end());
	reverse(gla.begin(), gla.end());
	int ans[n]={0};
	int c=0;
	for(auto [v,i]:gla){
		ans[i]=min(v,li);
		if(ans[i]==0)
			c++;
		li-=min(v,li);
	}
	cout<<c<<endl;
	for (int i = 0; i < n; ++i)
		cout<<ans[i]<<' ';
	cout<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 432 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct