# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
201824 |
2020-02-12T06:05:21 Z |
abil |
Sure Bet (CEOI17_sure) |
C++14 |
|
357 ms |
6776 KB |
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define all(s) s.begin(),s.end()
//#define int long long
#define double long double
using namespace std;
const int N = (1e6 + 12);
const int mod = (1e9 + 12);
const int inf = (1e9 + 12);
double a[N], b[N], pr[N];
bool cmp(double x, double y){
return x > y;
}
main()
{
int n;
scanf("%d", &n);
for(int i = 1;i <= n; i++){
cin >> a[i] >> b[i];
}
sort(a + 1,a + 1 + n, cmp);
sort(b + 1,b + 1 + n, cmp);
double ans = 0.000000000000000000, sum = 0.000000000000000000;
pr[0] = 0.000000000000000000;
for(int j = 1;j <= n; j++){
pr[j] = pr[j - 1] + b[j];
}
for(int i = 1;i <= n; i++){
sum += a[i];
int l = 1, r = n;
while(r - l > 1){
int mid = (r + l) >> 1;
if(pr[mid] > sum){
r = mid;
}
else{
l = mid;
}
}
for(int j = max(1, l - 100); j <= min(n, r + 100); j++){
double x = j, y = i;
ans = max(ans, min(pr[j], sum) - (x + y));
}
}
cout << fixed << setprecision(4) << ans;
}
Compilation message
sure.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
sure.cpp: In function 'int main()':
sure.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
7 ms |
376 KB |
Output is correct |
14 |
Correct |
8 ms |
376 KB |
Output is correct |
15 |
Correct |
8 ms |
376 KB |
Output is correct |
16 |
Correct |
9 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
376 KB |
Output is correct |
13 |
Correct |
7 ms |
376 KB |
Output is correct |
14 |
Correct |
8 ms |
376 KB |
Output is correct |
15 |
Correct |
8 ms |
376 KB |
Output is correct |
16 |
Correct |
9 ms |
376 KB |
Output is correct |
17 |
Correct |
333 ms |
4984 KB |
Output is correct |
18 |
Correct |
338 ms |
4984 KB |
Output is correct |
19 |
Correct |
333 ms |
4984 KB |
Output is correct |
20 |
Correct |
336 ms |
4984 KB |
Output is correct |
21 |
Correct |
352 ms |
4984 KB |
Output is correct |
22 |
Correct |
329 ms |
4984 KB |
Output is correct |
23 |
Correct |
343 ms |
5112 KB |
Output is correct |
24 |
Correct |
329 ms |
6392 KB |
Output is correct |
25 |
Correct |
331 ms |
6520 KB |
Output is correct |
26 |
Correct |
357 ms |
6776 KB |
Output is correct |