# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865371 |
2023-10-24T07:45:50 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
62 ms |
4956 KB |
#include <bits/stdc++.h>
#define pb push_back
#define all(q) q.begin (), q.end ()
#define ll long long
#define f first
#define s second
using namespace std;
const ll MOD = 1e9 + 7;
const ll inf = 1e9 + 1;
const ll INF = 1e18 + 1;
const ll N = 2e6 + 1;
const int k = 15;
double a[N], b[N];
void solve (){
int n;
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
// a[i] -= 1;
// b[i] -= 1;
}
sort (a + 1, a + 1 + n);
sort (b + 1, b + 1 + n);
reverse (a + 1, a + 1 + n);
reverse (b + 1, b + 1 + n);
// cout << '\n';
// for (int i = 1; i <= n; ++i) cout << a[i] << ' ' << b[i] << '\n';
// cout << '\n';
int l = 1, r = 1, t = 0;
double q = 0, w = 0, ans = 0;
while (l != n + 1 && r != n + 1){
while (l != n + 1 && q <= w){
// cout << l << ' ';
q += a[l];
++t;
++l;
// cout << q << ' ' << w << '\n';
ans = max (ans, min (q, w) - t);
}
while (r != n + 1 && q >= w){
// cout << r << ' ';
w += b[r];
++r;
++t;
// cout << q << ' ' << w << '\n';
ans = max (ans, min (q, w) - t);
}
}
printf("%.4lf",(double) ans);
}
main (){
ios_base::sync_with_stdio (0);
cin.tie (0);
// freopen("guard.in", "r", stdin);
// freopen("guard.out", "w", stdout);
ll t = 1;
// cin >> t;
for (ll i = 1; i <= t; ++i){
// cout << "Case " << i << ':' << '\n';
solve ();
// cout << '\n';
}
}
Compilation message
sure.cpp:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
57 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
55 ms |
4700 KB |
Output is correct |
18 |
Correct |
56 ms |
4700 KB |
Output is correct |
19 |
Correct |
62 ms |
4956 KB |
Output is correct |
20 |
Correct |
55 ms |
4696 KB |
Output is correct |
21 |
Correct |
59 ms |
4700 KB |
Output is correct |
22 |
Correct |
55 ms |
4568 KB |
Output is correct |
23 |
Correct |
58 ms |
4696 KB |
Output is correct |
24 |
Correct |
55 ms |
4696 KB |
Output is correct |
25 |
Correct |
56 ms |
4696 KB |
Output is correct |
26 |
Correct |
58 ms |
4696 KB |
Output is correct |