Submission #1111162

#TimeUsernameProblemLanguageResultExecution timeMemory
1111162Ghulam_JunaidSure Bet (CEOI17_sure)C++17
100 / 100
92 ms3764 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; pair<double, double> dp[N][N]; int main(){ int n; cin >> n; vector<double> a, b; for (int i=0; i<n; i++){ double x, y; cin >> x >> y; a.push_back(x); b.push_back(y); } sort(a.begin(), a.end(), greater<double>()); sort(b.begin(), b.end(), greater<double>()); double A = a[0] - 2; double B = b[0] - 2; double ans = max((double)0, min(A, B)); int p1 = 1; int p2 = 1; while (p1 != n || p2 != n){ if (A > B && p2 < n){ A--; B--; B += b[p2]; p2++; } else if (A <= B && p1 < n){ A--; B--; A += a[p1]; p1++; } else break; ans = max(ans, min(A, B)); } printf("%.4lf", ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...