Submission #667294

#TimeUsernameProblemLanguageResultExecution timeMemory
667294raypeng1729Sails (IOI07_sails)C++17
10 / 100
22 ms3668 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int INF = 1e16; signed main(){ ios::sync_with_stdio(false), cin.tie(0); int n; cin >> n; int a[n], b[n], mx = 0; for(int i = 0; i < n; i++) cin >> a[i] >> b[i], mx = max(mx, a[i]); int pre[mx + 1]{}; for(int i = 0; i < n; i++){ pre[0]++, pre[a[i] + 1]--; } for(int i = 1; i <= mx; i++) pre[i] += pre[i - 1]; int ans = 0, cnt = accumulate(b, b + n, 0); ans -= cnt; for(int i = mx; i > 0; i--){ int cur = min(pre[i], cnt / i); ans += cur * cur; cnt -= cur; } cout << ans / 2; }
#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...