Submission #1027630

#TimeUsernameProblemLanguageResultExecution timeMemory
1027630vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
68 ms3192 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> using namespace std; const int maxn = 1e5+3; int n; double a[maxn], b[maxn]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; a[i] = a[i] - 1.0; b[i] = b[i] - 1.0; } sort(a+1, a+n+1, greater<double>()); sort(b+1, b+n+1, greater<double>()); int i = 1, j = 1; double res = 0; double suma = 0, sumb = 0; while(i <= n){ suma += a[i]; i++; while(j <= n && min(suma - j + 1, sumb - i + 1) <= min(suma - j, sumb + b[j] - i + 1)){ sumb += b[j]; j++; } res = max(res, min(suma - j + 1, sumb - i + 1)); } cout << fixed << setprecision(4) << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...