제출 #642667

#제출 시각아이디문제언어결과실행 시간메모리
642667ymmSure Bet (CEOI17_sure)C++17
60 / 100
2073 ms3144 KiB
#include <bits/stdc++.h> #define Loop(x,l,r) for (ll x = (l); x < (r); ++x) #define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x) typedef long long ll; typedef std::pair<int, int> pii; typedef std::pair<ll , ll > pll; using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2") #define MAX(x, y) ((x)>(y)?(x):(y)) #define MIN(x, y) ((x)<(y)?(x):(y)) const int N = 100'010; double a[N], b[N]; int n; int main() { cin.tie(0) -> sync_with_stdio(false); cin >> n; Loop (i,1,n+1) { cin >> a[i] >> b[i]; } sort(a+1, a+n+1); reverse(a+1, a+n+1); sort(b+1, b+n+1); reverse(b+1, b+n+1); Loop (i,0,n) { a[i+1] += a[i]; b[i+1] += b[i]; } reverse(b, b+n+1); double ans = 0; Loop (j,0,n+1) { double x = 0; Loop (i,0,n+1-j) x = MAX(x, MIN(a[i], b[j+i])); ans = MAX(ans, x - (n - j)); } Loop (i,1,n+1) { double x = 0; Loop (j,0,n+1-i) x = MAX(x, MIN(a[i+j], b[j])); ans = MAX(ans, x - (n + i)); } cout << fixed << setprecision(4) << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...