# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844628 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<<" ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |