#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>
#define float double
using namespace std;
vector<float> A, B;
int main(){
int n; cin >> n;
for(int i = 0; i< n; i++){
float c, d; cin >> c >> d;
if(c>1)A.pb(c);
if(d>1)B.pb(d);
}
sort(A.begin(), A.end());
sort(B.begin(), B.end());
reverse(A.begin(), A.end());
reverse(B.begin(), B.end());
int p1 = 0;
int p2 = 0;
float v1 = 0;
float v2 = 0;
float ans = 0;
while(1){
if(v1 < v2){
if(p1 == A.size())break;
v1+=A[p1]-1;
v2-=1;
p1++;
}else{
if(p2 == B.size())break;
v1-=1;
v2+=B[p2]-1;
p2++;
}
ans = max(ans, min(v1, v2));
}
printf("%.4lf", (float)ans);
return 0;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(p1 == A.size())break;
~~~^~~~~~~~~~~
sure.cpp:33:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(p2 == B.size())break;
~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
368 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
368 KB |
Output is correct |
15 |
Correct |
4 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
136 ms |
3512 KB |
Output is correct |
18 |
Correct |
135 ms |
3424 KB |
Output is correct |
19 |
Correct |
129 ms |
3428 KB |
Output is correct |
20 |
Correct |
129 ms |
3336 KB |
Output is correct |
21 |
Correct |
149 ms |
3936 KB |
Output is correct |
22 |
Correct |
133 ms |
3452 KB |
Output is correct |
23 |
Correct |
130 ms |
3424 KB |
Output is correct |
24 |
Correct |
131 ms |
3364 KB |
Output is correct |
25 |
Correct |
129 ms |
3464 KB |
Output is correct |
26 |
Correct |
146 ms |
3808 KB |
Output is correct |