Submission #49433

#TimeUsernameProblemLanguageResultExecution timeMemory
49433dooweySure Bet (CEOI17_sure)C++14
100 / 100
124 ms16984 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef double db; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define TEST freopen("in.txt","r",stdin); #define ab(a) ((a < 0) ? (-(a)) : (a)) #define all(a) a.begin(), a.end() int main(){ fastIO; int n; cin >> n; db a[n]; db b[n]; for(int i = 0;i < n; i++ ){ cin >> a[i] >> b[i]; a[i] -- ; b[i] -- ; } sort(a, a + n); sort(b, b + n); reverse(a, a + n); reverse(b, b + n); db sum1 = 0;int cnt1 = 0; db sum2 = 0;int cnt2 = 0; db ans = 0; for(int i = 0;i < n;i ++ ){ sum1 += a[i]; cnt1 ++ ; ans = max(ans, min(sum1-cnt2,sum2-cnt1)); while(sum1-cnt2 > sum2-cnt1 and cnt2 < n){ sum2 += b[cnt2]; cnt2++; ans = max(ans, min(sum1-cnt2,sum2-cnt1)); } ans = max(ans, min(sum1-cnt2,sum2-cnt1)); } cout << fixed << setprecision(4) << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...