제출 #1126492

#제출 시각아이디문제언어결과실행 시간메모리
1126492vladiliusSure Bet (CEOI17_sure)C++20
100 / 100
68 ms2780 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<double> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]>>b[i]; } sort(a.begin() + 1, a.end(), greater<double>()); sort(b.begin() + 1, b.end(), greater<double>()); vector<double> mx(n + 1); for (int i = 1; i <= n; i++){ a[i] += a[i - 1]; b[i] += b[i - 1]; mx[i] = max(mx[i - 1], (b[i] - i)); } vector<double> :: iterator it; double out = 0; for (int i = 1; i <= n; i++){ it = lower_bound(b.begin() + 1, b.end(), a[i]); int j = (int) (it - b.begin()); if (j <= n) out = max(out, a[i] - (i + j)); if (j > 1) out = max(out, mx[j - 1] - i); } printf("%.4lf", out); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...