# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
890169 | HADI_T | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 604 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>
#define int long long
#define pb(x) push_back(x)
#define in(x) insert(x)
#define F first
#define S second
#define endl '\n'
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
const int M=1e9+7;
const int N=2e5+10;
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin>>n;
int sum = 0;
int ans[n+10]={0};
pair<int,int>a[n+10];
for(int i=1;i<=n;i++)
{
int x,y;
cin>>x>>y;
sum += x;
a[i]={y,i};
}
sort(a+1,a+1+n);
for(int i = n;i>=1;i--)
{
int ad = min(sum , a[i].F);
ans[a[i].S] += ad;
sum -= ad;
}
int cnt = 0;
for(int i=1;i<=n;i++)
{
if(ans[i] == 0)
cnt++;
}
cout<<cnt<<endl;
for(int i=1;i<=n;i++)
cout<<ans[i]<<' ';
cout<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |