Submission #593320

#TimeUsernameProblemLanguageResultExecution timeMemory
593320stevancvSure Bet (CEOI17_sure)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 5e5 + 2; const int mod = 1e9 + 7; int main() { ios::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++) { cin >> a[i] >> b[i]; } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); for (int i = 1; i < n; i++) a[i] += a[i - 1]; for (int i = 1; i < n; i++) b[i] += b[i - 1]; for (ld i : a) cout << i << sp; cout << en; for (ld i : b) cout << i << sp; cout << en; ld ans = 0; for (int rep = 0; rep < 2; rep++) { int j = 0; for (int i = 0; i < n; i++) { while (j < n && b[j] < a[i]) j++; if (j < n) smax(ans, a[i] - i - j - 2); } swap(a, b); } cout << fixed << showpoint << setprecision(4) << ans << en; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...