# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844639 | 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;
ll m=0;
vector<pair<ll,int>> Z;
for(int i=0;i<N;i++){
ll t,x;cin>>t>>x;
m+=t;
Z.push_back(make_pair(x,i));
}
sort(Z.begin(),Z.end(),greater<pair<ll,int>>());
ll p=0;
vector<ll> ZR(N);
for(int i=0;i<N;i++){
ZR[Z[i].second] = min(m,Z[i].first);
m-=ZR[Z[i].second];
if(ZR[Z[i].second]==0){p++;}
}
cout<<p<<endl;
for(auto &i:ZR)cout<<i<<" ";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |