#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
vector<int> a;
int n,i = 0,t,z,cnt = 0;cin >> n;
for(int i = 0;i<n;i++){
cin >> t >> z;
cnt += t;
a.push_back(z);
}
sort(a.begin(),a.end(),greater<int>());
while(cnt>0) cnt -= a[i++];
cout << n - i << endl;
for(int j = 0;j<i-1;j++) cout << a[j] << " ";
cout << cnt + a[i-1] << " ";
for(int j = i;j<n;j++) cout << 0 << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
6 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
7 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
8 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |