# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669335 |
2022-12-06T09:12:50 Z |
raypeng1729 |
Sails (IOI07_sails) |
C++17 |
|
25 ms |
3776 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin(), v.end()
const int N = 1e4, INF = 1e9 + 1, MOD = 1e9 + 7, K = __lg(N) + 1;
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 + 2]{};
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);
for(int i = mx; i > 0; i--){
int cur = min(pre[i], cnt / i);
ans += cur * (cur - 1) / 2;
cnt -= cur;
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
636 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
3000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
3540 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
25 ms |
3776 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |