# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938361 |
2024-03-05T05:05:04 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
68 ms |
1992 KB |
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ordered_mset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double INF = 1e4,N = 1e6;
int binpow (int a, int n) {
if (n == 0)
return 1;
if (n % 2 == 1)
return binpow (a, n-1) * a;
else {
int b = binpow (a, n/2);
return b * b;
}
}
void solve(){
int n;
cin >> n;
double a[n],b[n];
for(int i = 0;i < n;i++){
cin >> a[i] >> b[i];
}
sort(a,a + n);
sort(b,b + n);
reverse(a,a + n);
reverse(b,b + n);
double ans = 0;
int i = 0,j = 0;
double suma = 0,sumb = 0;
int cnt = 0;
int res = 0;
while(true){
if(suma - cnt <= sumb - cnt && i < n){
suma += a[i];
i++;
cnt++;
} else if(j < n){
sumb += b[j];
j++;
cnt++;
}
ans = max(ans,min(suma - cnt,sumb - cnt));
if(res == N){
break;
}
res++;
}
cout << fixed << setprecision(4);
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
452 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
452 KB |
Output is correct |
12 |
Correct |
3 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
57 ms |
1992 KB |
Output is correct |
18 |
Correct |
55 ms |
1884 KB |
Output is correct |
19 |
Correct |
56 ms |
1884 KB |
Output is correct |
20 |
Correct |
56 ms |
1880 KB |
Output is correct |
21 |
Correct |
68 ms |
1884 KB |
Output is correct |
22 |
Correct |
55 ms |
1884 KB |
Output is correct |
23 |
Correct |
56 ms |
1884 KB |
Output is correct |
24 |
Correct |
56 ms |
1992 KB |
Output is correct |
25 |
Correct |
56 ms |
1884 KB |
Output is correct |
26 |
Correct |
63 ms |
1884 KB |
Output is correct |