#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+(s==0)<<endl;
for(int j=0; j<n; j++) cout<<ans[j]<<' ';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
6 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |