Submission #1232326

#TimeUsernameProblemLanguageResultExecution timeMemory
1232326wojtupSure Bet (CEOI17_sure)C++20
100 / 100
69 ms6668 KiB
#include <algorithm> #include <iostream> #include <iomanip> #include <vector> using namespace std; typedef long double ld; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; vector<ld> A(n), B(n); for (int i = 0; i < n; i++) { ld a, b; cin >> a >> b; A.push_back(a-1.0); B.push_back(b-1.0); } sort(A.begin(), A.end()); reverse(A.begin(), A.end()); sort(B.begin(), B.end()); reverse(B.begin(), B.end()); ld wynik = 0.0; ld wynA = 0.0, wynB = 0.0; int idxB = 0; for (int i = 0; i < n; i++) { wynik = max(wynik, min(wynA, wynB)); wynA += A[i]; wynB -= 1.0; while (idxB < n and min(wynA, wynB) <= min(wynA-1.0, wynB+B[idxB])) { wynB += B[idxB]; wynA -= 1.0; idxB++; } } wynik = max(wynik, min(wynA, wynB)); cout << fixed << setprecision(4) << wynik << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...