# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
681490 |
2023-01-13T07:25:59 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++14 |
|
72 ms |
3564 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;
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 |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 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 |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
70 ms |
3216 KB |
Output is correct |
18 |
Correct |
72 ms |
3236 KB |
Output is correct |
19 |
Correct |
70 ms |
3148 KB |
Output is correct |
20 |
Correct |
69 ms |
3232 KB |
Output is correct |
21 |
Incorrect |
72 ms |
3564 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |