# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
681492 |
2023-01-13T07:32:22 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++14 |
|
75 ms |
3540 KB |
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<double, double> pdd;
void print() {cerr << '\n';} template <typename T1, typename... T2>
void print(const T1 &a, const T2 &...b) { cerr << a << ' ', print(b...); }
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
double a[N], b[N];
double res = 0;
int n;
void solve()
{
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
sort(a + 1, a + 1 + n, greater<double>());
sort(b + 1, b + 1 + n, greater<double>());
int i = 0, j = 0;
double sa = 0, sb = 0;
while(true)
{
if(i > n && j > n) break;
if(j > n)
sa += a[++i];
else if(i > n)
sb += b[++j];
else if(sa < sb)
sa += a[++i];
else
sb += b[++j];
res = max(res, min(sa, sb) - i - j);
}
cout << setprecision(4) << fixed << res;
}
signed main()
{
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
2 ms |
340 KB |
Output is correct |
17 |
Correct |
71 ms |
1904 KB |
Output is correct |
18 |
Correct |
70 ms |
1868 KB |
Output is correct |
19 |
Correct |
66 ms |
1740 KB |
Output is correct |
20 |
Correct |
68 ms |
1784 KB |
Output is correct |
21 |
Correct |
72 ms |
1816 KB |
Output is correct |
22 |
Correct |
72 ms |
3136 KB |
Output is correct |
23 |
Correct |
73 ms |
3208 KB |
Output is correct |
24 |
Correct |
75 ms |
3244 KB |
Output is correct |
25 |
Correct |
70 ms |
3208 KB |
Output is correct |
26 |
Correct |
72 ms |
3540 KB |
Output is correct |