Submission #736510

#TimeUsernameProblemLanguageResultExecution timeMemory
736510vjudge1Pod starim krovovima (COCI20_psk)C++14
50 / 50
1 ms340 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; ll int top=0; ll int arr[n]; memset(arr,0,sizeof(arr)); vector<pair<ll int,int>> v;// volum index for(int i=0;i<n;i++){ ll 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; ll 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...