Submission #321867

#TimeUsernameProblemLanguageResultExecution timeMemory
321867Karen124Sure Bet (CEOI17_sure)C++14
0 / 100
1 ms364 KiB
#pragma GCC optimize("O2") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define ll long long int #define F first #define S second #define pb push_back const ll N = 1000 + 10; const ll LOG = 20; const ll MOD = 1e9 + 7; const ll INF = 1e9 + 10; int n; long double a[N], b[N], ans = 0, psa[N], psb[N]; long double f(int i, int j){ return min(psa[i] - (long double)j, psb[j] - (long double)i); } int main() { cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; a[i] --; b[i] --; } sort(a + 1, a + n + 1); reverse(b + 1, b + n + 1); sort(b + 1, b + n + 1); reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i++){ psa[i] = psa[i - 1] + a[i]; psb[i] = psb[i - 1] + b[i]; } for (int i = 1; i <= n; i++){ int l = 0, r = n; while (l + 1 <= r){ int mid = (l + r) / 2; if (f(i, mid) < f(i, mid + 1)) l = mid + 1; else r = mid; } } 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...