# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844292 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++98 | 1 ms | 348 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;
int main(){
long long a,b,c,d,p,h,y,u,n;
vector <pair <long long,long long> > arr;
vector <pair <long long,long long> > den;
long long arr1[10005];
cin>>a;
y=0;
p=a;
n=1;
while(a--){
cin>>b>>c;
y+=b;
arr.push_back(make_pair(c,b));
den.push_back(make_pair(c,n-1));
n++;
}
d=0;
sort(arr.begin(),arr.end(), greater <pair <long long, long long> >());
sort(den.begin(),den.end(), greater <pair <long long, long long> >());
for(long long i;p>i;i++){
if(arr[i].first <= y){
y-= arr[i].first;
arr[i].second = arr[i].first;
}
else{
if(y == 0){
arr[i].second = 0;
d++;
}
else{
arr[i].second = y;
y=0;
}
}
}
for(long long i;p>i;i++){
arr1[den[i].second] = arr[i].second;
}
cout<<d<<"\n";
for(long long i;p>i;i++){
cout<<arr1[i]<<" ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |