# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844407 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 2 ms | 344 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;
#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 |
---|---|---|---|---|
Fetching results... |