Submission #471106

#TimeUsernameProblemLanguageResultExecution timeMemory
471106Killer2501Sure Bet (CEOI17_sure)C++14
0 / 100
2 ms2636 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define pb push_back #define task "tests" #define pll pair<ll, ll> #define pi pair<ll, pll> #define fi first #define se second using namespace std; const ll mod = 1000000000; const ll N = 1e5+55; const int base = 313; ll n, m, t, k, T, ans, q, tong; ll a[N], b[N], d[N]; vector<ll> adj[N], kq; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } bool cmp(ll& x, ll& y) { return x > y; } bool check(ll x) { ll total = 0; for(int i = 1; i <= n; i ++) { total += b[i] - mod; ll j = min(n, (total - x) / mod); if(j < 0)continue; if(d[j] - mod * i >= x)return true; } return false; } void sol() { cin >> n; for(int i = 1; i <= n; i ++) { double x; cin >> x; a[i] = mod * x; cin >> x; b[i] = mod * x; } sort(a+1, a+1+n, cmp); sort(b+1, b+1+n, cmp); for(int i = 1; i <= n; i ++)d[i] = max(d[i-1], d[i-1] + a[i] - mod); ll lf = 0, rt = mod * mod, mid; //cout << rt; while(lf <= rt) { mid = (lf + rt) / 2; if(check(mid))lf = mid+1; else rt = mid - 1; } cout << fixed << setprecision(4) << (ld) 1.0 * rt / mod; } int main() { if(fopen(task".in", "r")) { freopen(task".in", "r", stdin); freopen(task".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); }

Compilation message (stderr)

sure.cpp: In function 'int main()':
sure.cpp:73:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:74:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...