# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027458 |
2024-07-19T06:42:26 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
89 ms |
7764 KB |
#include<bits/stdc++.h>
#ifdef LOCAL
#include "D:\debug.h"
#else
#define cebug(...) "Orz_chUoNgnn_khanhtb_0x2ee08"
#endif
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define cd complex<double>
#define ld long double
const ll mod = 1e9 + 7;
const ll INF = 1e18L + 5;
const double PI = acos(-1);
const int block = 320;
const int N = 2e5;
int tc, tt = 1;
int n;
ld a[N + 5], b[N + 5];
ld f[N + 5];
ld eps = 0.000000001;
void solve() {
cin>>n;
for(int i=1; i<=n; i++) cin>>a[i]>>b[i];
ld ans = 0;
sort(a + 1, a + 1 + n, greater<ld>());
sort(b + 1, b + 1 + n, greater<ld>());
for(int l=1; l<=2; l++) {
for(int i=1; i<=n; i++) f[i] = f[i - 1] + b[i];
ld sum = 0;
for(int i=1; i<=n; i++) {
sum += a[i];
ld mi = 1e9;
int l = 1, r = n;
while(l <= r) {
int mid = (l + r)/2;
if(f[mid] - sum >= 0.0) {
mi = mid;
r = mid - 1;
}
else l = mid + 1;
}
ans = max(ans, sum - i - mi);
}
for(int i=1; i<=n; i++) swap(a[i], b[i]);
}
cout<<fixed<<setprecision(4)<<ans;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
for(tc=1; tc<=tt; tc++) solve();
cerr<<"\nTime elapsed: "<<1000.0*clock()/CLOCKS_PER_SEC<<" ms.\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
2 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
1 ms |
4440 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
1 ms |
4444 KB |
Output is correct |
16 |
Correct |
2 ms |
4444 KB |
Output is correct |
17 |
Correct |
79 ms |
6480 KB |
Output is correct |
18 |
Correct |
89 ms |
7764 KB |
Output is correct |
19 |
Correct |
80 ms |
7616 KB |
Output is correct |
20 |
Correct |
81 ms |
7604 KB |
Output is correct |
21 |
Correct |
82 ms |
7504 KB |
Output is correct |
22 |
Correct |
80 ms |
7508 KB |
Output is correct |
23 |
Correct |
83 ms |
7584 KB |
Output is correct |
24 |
Correct |
82 ms |
7504 KB |
Output is correct |
25 |
Correct |
79 ms |
7608 KB |
Output is correct |
26 |
Correct |
85 ms |
6484 KB |
Output is correct |