Submission #488408

#TimeUsernameProblemLanguageResultExecution timeMemory
488408ammar2000Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms336 KiB
/* ___ ___ ___ ___ ___ / /\ /__/\ /__/\ / /\ / /\ / /::\ ::\ |::\ / /::\ / /::\ / /:/\:\ | |:|:\ | |:|:\ / /:/\:\ / /:/\:\ / /:/~/::\ __|__|:|\:\ __|__|:|\:\ / /:/~/::\ / /:/~/:/ /__/:/ /:/\:\ /__/::::| \:\ /__/::::| \:\ /__/:/ /:/\:\ /__/:/ /:/___ \ \:\/:/__\/ \ \:\~~\__\/ \ \:\~~\__\/ \ \:\/:/__\/ \ \:\/:::::/ \ \::/ \ \:\ \ \:\ \ \::/ \ \::/~~~~ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \ \:\ \__\/ \__\/ \__\/ \__\/ \__\/ ___ ___ ___ ___ ___ ___ / /\ / /\ /__/\ / /\ / /\ /__/\ / /::\ ___ / /::\ \ \:\ / /:/_ / /:/_ \ \:\ / /:/\:\ /__/\ ___ / /:/\:\ \__\:\ / /:/ /\ / /:/ /\ \ \:\ / /:/~/::\ \ \:\ / /\ / /:/~/:/ ___ / /::\ / /:/ /:/_ / /:/ /:/_ _____\__\:\ /__/:/ /:/\:\ \ \:\ / /:/ /__/:/ /:/ /__/\ /:/\:\ /__/:/ /:/ /\ /__/:/ /:/ /\ /__/::::::::\ \ \:\/:/__\/ \ \:\ /:/ \ \:\/:/ \ \:\/:/__\/ \ \:\/:/ /:/ \ \:\/:/ /:/ \ \:\~~\~~\/ \ \::/ \ \:\/:/ \ \::/ \ \::/ \ \::/ /:/ \ \::/ /:/ \ \:\ ~~~ \ \:\ \ \::/ \ \:\ \ \:\ \ \:\/:/ \ \:\/:/ \ \:\ \ \:\ \__\/ \ \:\ \ \:\ \ \::/ \ \::/ \ \:\ \__\/ \__\/ \__\/ \__\/ \__\/ \__\/ _ __ ___ ___ __| | ___ / _| ___ _ __ ___ ___ ___ _ / __/ _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __(_) | (_| (_) | (_| | __/ _| (_) | | | (_| __/\__ \_ \___\___/ \__,_|\___|_| \___/|_| \___\___||___(_) ____ ___ ___ ___ __ _ _ __ ___ _ __ ___ __ _ _ _|___ \ / _ \ / _ \ / _ \ / _` | '_ ` _ \| '_ ` _ \ / _` | '__|__) | | | | | | | | | | | (_| | | | | | | | | | | | (_| | | / __/| |_| | |_| | |_| | \__,_|_| |_| |_|_| |_| |_|\__,_|_| |_____|\___/ \___/ \___/ */ #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 timeMemoryGrader output
Fetching results...