#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 |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
276 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
276 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
432 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
276 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
432 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
118 ms |
4940 KB |
Output is correct |
18 |
Correct |
119 ms |
4828 KB |
Output is correct |
19 |
Correct |
121 ms |
4856 KB |
Output is correct |
20 |
Correct |
117 ms |
4856 KB |
Output is correct |
21 |
Correct |
127 ms |
5308 KB |
Output is correct |
22 |
Correct |
120 ms |
4988 KB |
Output is correct |
23 |
Correct |
118 ms |
4868 KB |
Output is correct |
24 |
Correct |
119 ms |
4856 KB |
Output is correct |
25 |
Correct |
118 ms |
4796 KB |
Output is correct |
26 |
Correct |
131 ms |
5240 KB |
Output is correct |