# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
732165 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 2 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.
//Test case unutma ve reset
//Sinirlari kontrol et
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1e9+7
#define OYY 1e12
#define ordu ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mid (start+end)/2
vector <pair<int,int>> v;
int dizi[1005];
int32_t main(){
ordu
int n;cin>>n;
int t[n],z[n];
int sum=0;
for(int i=0;i<n;i++){
cin>>t[i]>>z[i];
sum+=t[i];
v.push_back({z[i],i});
}
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
int k=0;
while(sum!=0){
if(sum>=v[k].first){
dizi[v[k].second]=v[k].first;
sum-=v[k].first;
}
else{
dizi[v[k].second]=sum;
sum=0;
}
k++;
}
cout<<n-k<<'\n';
for(int i=0;i<n;i++)cout<<dizi[i]<<" ";
cout<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |