# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488408 | ammar2000 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 336 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 ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int MOD=1e9+7;
ll n,sum,ans[SI],sth;
vector <pair <ll,ll> > p;
void solver()
{
cin>>n;
for (int i=0;i<n;i++)
{
ll b;
cin>>b;
sum+=b;
ll a;
cin>>a;
p.pb({a,i});
}
sort (p.begin(),p.end());
for (int i=n-1;i>=0&&sum>0;i--)
{
ans[p[i].S]=min(p[i].F,sum);
sum-=p[i].F;
sth++;
}
cout <<n-sth<<"\n";
for (int i=0;i<n;i++)
cout <<ans[i]<<" ";
}
int main()
{
solver();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |