Submission #139711

#TimeUsernameProblemLanguageResultExecution timeMemory
139711RiscadoASure Bet (CEOI17_sure)C++14
100 / 100
227 ms3684 KiB
#include <bits/stdc++.h> const int MAX_N = 100000; int N; double S[2][MAX_N]; inline double min(double a, double b) { return a < b ? a : b; } int main() { std::cin >> N; for (int i = 0; i < N; ++i) std::cin >> S[0][i] >> S[1][i]; std::sort(std::begin(S[0]), std::begin(S[0]) + N, std::greater<double>()); std::sort(std::begin(S[1]), std::begin(S[1]) + N, std::greater<double>()); double best = 0.0; double a = 0.0, b = 0.0; for (int i = 0, j = 0;;) { if (i >= N && j >= N) break; else if ((i < N && a <= b) || j >= N) { a += S[0][i] - 1.0; b -= 1.0; i += 1; } else { b += S[1][j] - 1.0; a -= 1.0; j += 1; } if (min(a, b) > best) best = min(a, b); } printf("%.4lf", best); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...