Submission #1027408

#TimeUsernameProblemLanguageResultExecution timeMemory
1027408vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
52 ms2020 KiB
#include<bits/stdc++.h> // #pragma GCC optimize("03,unroll-loops") // #pragma GCC target("avx2,fma,bmi2,lzcnt,popcnt") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("avx,avx2,fma") #define endl "\n" #define pb push_back #define rs resize using namespace std; void solve() { int n; cin >> n; double a[n], b[n]; for (int i = 0; i < n; ++i) { cin >> a[i] >> b[i]; a[i]--, b[i]--; } sort(a, a + n), reverse(a, a + n); sort(b, b + n); reverse(b, b + n); int j = 0, i = 0; long double sum_a = 0, sum_b = 0, res = 0; while (i < n) { sum_a += a[i]; i++; while (j < n && min(sum_a - j, sum_b - i) < min(sum_a - (j + 1), (sum_b + b[j]) - i)) { sum_b += b[j]; j++; } res = max(res, min(sum_a - j, sum_b - i)); } cout << fixed << setprecision(4) << res; } // le pham gia hung thich bu cu int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); // int t; cin >> t; // while (t--) solve(); return 0; } /* #define hung_lon long long #define le_pham_gia_hung_aka_le_phot_ra_tinh int #define anh_hung_bu_cu cin #define anh_hung_thoi_bu_cu cout #define le_pham_gia_hung_thich_bu_cu string #define le_pham_gia_hung_phot_ra_tinh char #define le_pham_gia_hung_bu_cu_suot_ngay long double */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...