Submission #734910

#TimeUsernameProblemLanguageResultExecution timeMemory
734910DangerNoodle7591Pod starim krovovima (COCI20_psk)C++17
40 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long #define lalala ios_base::sync_with_stdio(false);cin.tie(NULL); #define mod 1000000007 #define N 1005 #define big 1000000000000000007 int main(){ lalala; int n;cin>>n; int top=0; int arr[n]; memset(arr,0,sizeof(arr)); vector<pair<int,int>> v;// volum index for(int i=0;i<n;i++){ int a,b;cin>>a>>b; top+=a; v.push_back({b,i}); } sort(v.begin(),v.end(),greater<>()); int cev=n; for(auto u:v){ if(top==0)break; int vol=u.first,indek=u.second; cev--; if(vol>=top){ arr[indek]=top; top=0;break; } top-=vol; arr[indek]=vol; } cout<<cev<<endl; for(int i=0;i<n;i++){ cout<<arr[i]<<" "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...