Submission #412424

#TimeUsernameProblemLanguageResultExecution timeMemory
412424DaktoSails (IOI07_sails)C++17
0 / 100
127 ms6832 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<pair<int,int>> v(n); for(int i=0; i<n; i++) cin>>v[i].first>>v[i].second; long long res=1e16; unordered_map<int,long long> m; long long s=0; for(auto i:v) m[i.first]+=i.second; for(auto i:v) s+=i.second; auto check=[&](long long c){ long long v=0; long long tr=0; long long ts=0; for(int i=100000; i>=1; i--){ v+=m[i]; int d=min(v,c-(s-ts<=i?1:0)); tr+=d*(d-1)/2; v-=d; ts+=m[i]; } if(!v) res=min(res,tr); return v==0; }; int l=1, r=1e5; while(l<r){ int m=(l+r)/2; if(check(m)) r=m; else l=m+1; } cout<<res<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...