제출 #498449

#제출 시각아이디문제언어결과실행 시간메모리
498449syrtinSure Bet (CEOI17_sure)C++17
100 / 100
92 ms3012 KiB
#include <bits/stdc++.h> #define pb push_back #define all(v) v.begin(),v.end() #define ff first #define ss second using namespace std; typedef long long ll; typedef pair<long long, long long> pll; typedef pair < int, int > pii; typedef vector<int> vi; typedef vector<long long> vll; const int N = 2e5 + 123; const ll mod = 1e9 + 7; void solve(){ int n, cnt = 0; cin >> n; double a[n], b[n], out = 0, s = 0; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a, a + n), sort(b, b + n); for(int i = n - 2; i >= 0; i--) b[i] += b[i + 1]; for(int i = n - 1; i >= 0; i--) { s += a[i] - 1; int p = s; cnt++; int l = max(n - 1 - p, -1), r = n; while(l + 1 < r) { int mi = l + (r - l) / 2; if(b[mi] - cnt <= s)r = mi; else l = mi; } if(r != n)out = max(out, b[r] - cnt - (n - r)); if(r)out = max(out, s - (n - r) - 1); } cout << fixed << setprecision(4) << out; } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); ios_base::sync_with_stdio(false); cin.tie(0); int times = 1; //cin >> times; while(times--)solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...