# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
868754 | pcc | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 464 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 pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const ll mxn = 1010;
pll arr[mxn];
ll ans[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
ll sum = 0;
priority_queue<pll,vector<pll>,less<pll>> pq;
for(int i =1;i<=n;i++){
cin>>arr[i].fs>>arr[i].sc;
pq.push({arr[i].sc,i});
sum += arr[i].fs;
}
while(sum>pq.top().fs){
ans[pq.top().sc] = pq.top().fs;
sum -= pq.top().fs;
pq.pop();
}
ans[pq.top().sc] = sum;
ll cnt = 0;
for(int i = 1;i<=n;i++)if(!ans[i])cnt++;
cout<<cnt<<'\n';
for(int i = 1;i<=n;i++)cout<<ans[i]<<' ';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |