# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938281 |
2024-03-05T04:04:46 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
118 ms |
6740 KB |
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>*/
template<class S,class T>
bool chmin(S &a,const T &b) {
return a>b?(a=b)==b:false;
}
template<class S,class T>
bool chmax(S &a,const T &b) {
return a<b?(a=b)==b:false;
}
//void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const ll inf=1e18;
const ld mod=1e10;
const ll N=1e5+5;
const ld eps=1e-6;
ld pr1[N],pr2[N];
void solve(){
ll i,j;
ll n;
cin>>n;
vector<ld> a(n),b(n);
for(i=0;i<n;i++) cin>>a[i]>>b[i];
sort(rall(a));
sort(rall(b));
while(a.sz && a.bc<=1)a.pob;
while(b.sz && b.bc<=1)b.pob;
pr1[0]=pr2[0]=0;
for(i=1;i<=a.sz;i++) pr1[i]=pr1[i-1]+a[i-1];
for(i=1;i<=b.sz;i++) pr2[i]=pr2[i-1]+b[i-1];
ld l=0,r=mod;
while(l+eps<r){
ld mid=(l+r)/2;
i=0,j=0;
while(i<=a.sz && j<=b.sz){
if(pr1[i]-i-j>=mid && pr2[j]-i-j>=mid)break;
if(pr1[i]<pr2[j])i++;
else j++;
}
if(i>a.sz || j>b.sz)r=mid;
else l=mid;
}
cout<<fixed<<setprecision(4)<<l<<endl;
}
signed main(){
start();
ll t=1;
//cin>>t;
while(t--) solve();
return 0;
}
/*
*/
Compilation message
sure.cpp: In function 'void solve()':
sure.cpp:57:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(i=1;i<=a.sz;i++) pr1[i]=pr1[i-1]+a[i-1];
| ^
sure.cpp:58:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(i=1;i<=b.sz;i++) pr2[i]=pr2[i-1]+b[i-1];
| ^
sure.cpp:63:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | while(i<=a.sz && j<=b.sz){
| ^
sure.cpp:63:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | while(i<=a.sz && j<=b.sz){
| ^
sure.cpp:68:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | if(i>a.sz || j>b.sz)r=mid;
| ^
sure.cpp:68:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | if(i>a.sz || j>b.sz)r=mid;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 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 |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2548 KB |
Output is correct |
14 |
Correct |
2 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
2 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
2 ms |
2396 KB |
Output is correct |
13 |
Correct |
2 ms |
2548 KB |
Output is correct |
14 |
Correct |
2 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
106 ms |
6736 KB |
Output is correct |
18 |
Correct |
99 ms |
6488 KB |
Output is correct |
19 |
Correct |
104 ms |
6480 KB |
Output is correct |
20 |
Correct |
97 ms |
6716 KB |
Output is correct |
21 |
Correct |
111 ms |
6484 KB |
Output is correct |
22 |
Correct |
98 ms |
6484 KB |
Output is correct |
23 |
Correct |
99 ms |
6480 KB |
Output is correct |
24 |
Correct |
108 ms |
6680 KB |
Output is correct |
25 |
Correct |
97 ms |
6720 KB |
Output is correct |
26 |
Correct |
118 ms |
6740 KB |
Output is correct |