Submission #918003

#TimeUsernameProblemLanguageResultExecution timeMemory
918003abczzSails (IOI07_sails)C++14
55 / 100
39 ms2896 KiB
#include <iostream> #include <vector> #include <array> #define ll long long using namespace std; bool ok; vector <ll> V; ll n, a, b, k, l, r, z, mid, s, t, f, ps[100001], cnt[100001]; int main() { cin >> n; for (int i=0; i<n; ++i) { cin >> a >> b; --a; ps[a] += b; t += b; ++cnt[a+1]; } for (int i=1; i<100000; ++i) { ps[i] += ps[i-1]; cnt[i] += cnt[i-1]; } l = 0, r = n; while (l < r) { mid = (l+r)/2; s = 0; ok = 1; for (int i=0; i<100000; ++i) { s += min(n-cnt[i], mid); if (s < ps[i]) { ok = 0; break; } } if (ok) r = mid; else l = mid+1; } for (int i=0; i<100000; ++i) { s = min(n-cnt[i], l); z += s; f += s * (s-1) / 2; } f -= (z-t) * (l-1); cout << f << '\n'; }
#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...