Submission #51820

#TimeUsernameProblemLanguageResultExecution timeMemory
51820istleminSure Bet (CEOI17_sure)C++14
100 / 100
124 ms4376 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i<int(b);++i) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define trav(a,c) for(auto a: c) typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; ll n; vector<double> a; vector<double> b; /* double best = 0; void getBest(ll index, double sumA, double sumB){ if(index==n){ best = max(best,min(sumA,sumB)); return; } getBest(index+1,sumA+a[index]-2,sumB+b[index]-2); getBest(index+1,sumA+a[index]-1,sumB-1); getBest(index+1,sumA-1,sumB+b[index]-1); getBest(index+1,sumA,sumB); }*/ int main(){ cin.sync_with_stdio(false); cin>>n; a.resize(n); b.resize(n); rep(i,0,n) cin>>a[i]>>b[i]; //getBest(0,0,0); sort(all(a)); sort(all(b)); reverse(all(a)); reverse(all(b)); vector<double> sumA(n+1); rep(i,0,n) sumA[i+1] = sumA[i] + a[i]; vector<double> sumB(n+1); rep(i,0,n) sumB[i+1] = sumB[i] + b[i]; double best = 0; rep(i,1,n+1){ ll bi = lower_bound(all(sumB),sumA[i])-sumB.begin(); rep(j,bi-1,bi+2){ if(j<1||j>n) continue; best = max(best,min(sumA[i]-i-j,sumB[j]-i-j)); } } printf("%.4lf",(double)best); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...