Submission #732165

#TimeUsernameProblemLanguageResultExecution timeMemory
732165vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
2 ms340 KiB
//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 timeMemoryGrader output
Fetching results...