#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ld niz1[100005];
ld niz2[100005];
int main() {
ios_base::sync_with_stdio(false);
cout.precision(4);
cout << fixed;
int n;
cin >> n;
for(int i=0; i<n; i++){
cin >> niz1[i];
cin >> niz2[i];
niz1[i]--;
niz2[i]--;
}
sort(niz1, niz1+n);
sort(niz2, niz2+n);
reverse(niz1, niz1+n);
reverse(niz2, niz2+n);
int j=0;
ld res1=0;
ld res2=0;
ld maxres=0;
for(int i=0; i<n; i++){
res1 += niz1[i];
while(j < n && min(res1-j, res2-i-1) < min(res1-j-1, res2+niz2[j]-i-1)){
res2 += niz2[j];
j++;
}
maxres = max(maxres, min(res1-j, res2-i-1));
}
cout << maxres;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
332 KB |
Output is correct |
17 |
Correct |
102 ms |
4764 KB |
Output is correct |
18 |
Correct |
103 ms |
4720 KB |
Output is correct |
19 |
Correct |
113 ms |
4676 KB |
Output is correct |
20 |
Correct |
103 ms |
4704 KB |
Output is correct |
21 |
Correct |
113 ms |
5172 KB |
Output is correct |
22 |
Correct |
103 ms |
4792 KB |
Output is correct |
23 |
Correct |
103 ms |
4804 KB |
Output is correct |
24 |
Correct |
103 ms |
4804 KB |
Output is correct |
25 |
Correct |
103 ms |
4808 KB |
Output is correct |
26 |
Correct |
113 ms |
5160 KB |
Output is correct |