# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340594 | A_D | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 364 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.
/*
ID: antwand1
TASK: barn1
LANG: C++
*/
#include <bits/stdc++.h>
#define ll long long
#define du long double
#define F first
#define S second
using namespace std;
const int N=1e3+1;
pair<int,int> a[N];
int dp[N];
main()
{
//freopen("barn1.in","r",stdin);freopen("barn1.out","w",stdout);
int n,sum=0,ans=0;
cin>>n;
for(int i=1;i<=n;i++){
int b;
cin>>b;
sum+=b;
cin>>a[i].F;
a[i].S=i;
}
sort(a+1,a+n+1);
reverse(a+1,a+n+1);
for(int i=1;i<=n;i++){
int g=min(sum,a[i].F);
sum-=g;
dp[a[i].S]=g;
}
for(int i=1;i<=n;i++)
if(dp[i]==0)ans++;
cout<<ans<<endl;
for(int i=1;i<=n;i++)cout<<dp[i]<<" ";cout<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |