Submission #559201

#TimeUsernameProblemLanguageResultExecution timeMemory
559201fatemetmhrSure Bet (CEOI17_sure)C++17
100 / 100
101 ms3920 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) x.begin(), x.end() #define fi first #define se second #define pb push_back const int maxn5 = 1e6 + 10; vector <double> av[2]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for(int i = 0; i < n; i++){ double a, b; cin >> a >> b; av[0].pb(a); av[1].pb(b); } sort(all(av[0])); reverse(all(av[0])); sort(all(av[1])); reverse(all(av[1])); for(int i = 1; i < n; i++){ av[0][i] += av[0][i - 1]; av[1][i] += av[1][i - 1]; } double ans = 0; for(int i = 0; i < n; i++){ int pt = lower_bound(all(av[0]), av[1][i]) - av[0].begin(); if(pt < n) ans = max(ans, av[1][i] - i - pt - 2); pt = lower_bound(all(av[1]), av[0][i]) - av[1].begin(); if(pt < n) ans = max(ans, av[0][i] - i - pt - 2); } cout << setprecision(4) << fixed << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...