#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
int N;cin>>N;
vector<ll> T(N),Z(N);
for(int i=0;i<N;i++)cin>>T[i]>>Z[i];
ll m = accumulate(T.begin(),T.end(),0);
sort(Z.begin(),Z.end(),greater<ll>());
bool flag = true;
for(int i=0;i<N;i++){
ll dec = min(Z[i],m);
Z[i]=dec;
m-=dec;
if(m==0 && flag){cout<<N-i-1<<endl;flag=false;}
}
for(auto &i:Z)cout<<i<<" ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 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 |
Partially correct |
0 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 |