제출 #924378

#제출 시각아이디문제언어결과실행 시간메모리
924378NK_Sure Bet (CEOI17_sure)C++17
0 / 100
1 ms348 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define pb push_back #define sz(x) int(x.size()) using db = double; using ll = long long; template<class T> using V = vector<T>; using vi = V<int>; const int MUL = int(1e4); int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; vi A(N), B(N); for(int i = 0; i < N; i++) { db x, y; cin >> x >> y; A[i] = int(MUL * x), B[i] = int(MUL * y); } sort(rbegin(A), rend(A)); sort(rbegin(B), rend(B)); ll sa = A[0], sb = B[0], ans = 0; int a = 1, b = 1; while(1) { int x = a + b; ans = max(ans, min(sa - x * MUL, sb - x * MUL)); // cout << ans << " " << sa << " " << sb << " " << x << endl; if (sa == sb) { if (max(a, b) == N) break; sa += A[a++]; sb += B[b++]; } else if (sa < sb) { if (a == N) break; sa += A[a++]; } else if (sb > sa) { if (b == N) break; sb += B[b++]; } else break; } printf("%.4f", db(ans) / db(MUL)); exit(0-0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...