#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
double L,R;
const int N=100050;
double l[N],r[N],sol;
int main()
{
int n,i,j;
scanf("%i",&n);
for(i=1;i<=n;i++) cin >> l[i] >> r[i];
sort(l+1,l+1+n);
sort(r+1,r+1+n);
i=n,j=n;int cnt=0;
while(i || j)
{
cnt++;
if(!i) R+=r[j--];
else if(!j) L+=l[i--];
else if(L<R) L+=l[i--];
else R+=r[j--];
sol=max(sol,min(L,R)-cnt);
}
//printf("%.4llf\n",(double)sol);
cout << fixed << setprecision(4) << sol << "\n";
return 0;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%i",&n);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 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 |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
296 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 |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 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 |
380 KB |
Output is correct |
12 |
Correct |
4 ms |
376 KB |
Output is correct |
13 |
Correct |
4 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
376 KB |
Output is correct |
15 |
Correct |
4 ms |
376 KB |
Output is correct |
16 |
Correct |
4 ms |
296 KB |
Output is correct |
17 |
Correct |
188 ms |
3264 KB |
Output is correct |
18 |
Correct |
190 ms |
3196 KB |
Output is correct |
19 |
Correct |
190 ms |
3252 KB |
Output is correct |
20 |
Correct |
195 ms |
3192 KB |
Output is correct |
21 |
Correct |
221 ms |
3556 KB |
Output is correct |
22 |
Correct |
189 ms |
3304 KB |
Output is correct |
23 |
Correct |
197 ms |
3400 KB |
Output is correct |
24 |
Correct |
192 ms |
3284 KB |
Output is correct |
25 |
Correct |
191 ms |
3248 KB |
Output is correct |
26 |
Correct |
226 ms |
3732 KB |
Output is correct |