Submission #467561

#TimeUsernameProblemLanguageResultExecution timeMemory
467561idk321One-Way Streets (CEOI17_oneway)C++17
0 / 100
0 ms204 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100005; double odds [2][N]; double sum[2][N]; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> odds[0][i] >> odds[1][i]; } sort(odds[0], odds[0] + n, greater<double>()); sort(odds[1], odds[1] + n, greater<double>()); double val2 = odds[1][0]; int j = 0; double res = 0; double val1 = 0; for (int i = 0; i < n; i++) { val1 += odds[0][i]; while (j + 1 < n && min(val1, val2)- i - j - 2 < min(val1, val2 + odds[1][j + 1]) - i - j - 3) { j++; val2 += odds[1][j]; } res = max(res, min(val1, val2)- i - j - 2); } cout << fixed << setprecision(4) << res << "\n"; } /* 4 1.4 3.7 1.2 2 1.6 1.4 1.9 1.5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...