# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
734912 | DangerNoodle7591 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 340 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>
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |