Submission #1032986

#TimeUsernameProblemLanguageResultExecution timeMemory
1032986amine_arouaSure Bet (CEOI17_sure)C++17
100 / 100
160 ms3672 KiB
#include<bits/stdc++.h> using namespace std; void read(vector<double> &a , vector<double> &b , int &n) { cin>>n; a.assign(n , 0); b = a; for(int i = 0 ;i < n ; i++) { cin>>a[i]>>b[i]; } } void brute(vector<double> &a , vector<double> &b , int &n) { n = rand()%10 + 1; a.assign(n , 0); b = a; for(int i = 0 ;i < n ; i++) { a[i] = rand()%5 + 4; b[i] = rand()%5 + 4; } } int main() { int n ; vector<double> a , b; read(a , b , n); sort(a.rbegin() , a.rend()); sort(b.rbegin() , b.rend()); double ans1 = 0; for(int i = 0 ; i < n ; i++) { a[i]--; b[i]--; } for(int i = 1 ; i < n ; i++) { a[i]+=a[i - 1]; b[i]+=b[i - 1]; } for(int na = 1; na <= n ; na++) { double lo = 0 , hi = a[na - 1] - 1; for(int i = 0 ; i < 40 ; i++) { double md = (lo + hi)/2; if(b[max(0 , min((int)floor(a[na - 1] - md - 1) , n - 1))] >= na + md) { lo = md; } else hi = md; } ans1 = max(ans1 , lo); } printf("%.4lf",(double)ans1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...