Submission #471096

#TimeUsernameProblemLanguageResultExecution timeMemory
471096Killer2501Sure 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 = 1e9; const ll N = 1e5+55; const int base = 313; ll n, m, t, k, T, ans, q, tong, h[N], d[N], lab[N], fe[N]; ld a[N], b[N], c[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; } void add(ll id, ll x) { for(; id; id -= id & -id)fe[id] = max(fe[id], x); } ll get(ll id) { ll total = 0; for(; id <= n; id += id & -id)total = max(total, fe[id]); return total; } bool cmp(ld& x, ld& y) { return x > y; } bool check(ll x) { ll total = 0; for(int i = 1; i <= n; i ++) { total += b[i] - mod; int j = min(n, (total - x) / mod); if(j < 0)continue; if(d[j] >= i * mod + x)return true; } return false; } void sol() { cin >> n; for(int i = 1; i <= n; i ++) { cin >> a[i] >> b[i]; a[i] *= mod; b[i] *= mod; } 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] +(ll) a[i] - mod); ll lf = 0, rt = mod * mod, mid; while(lf <= rt) { mid = (lf + rt) / 2; if(check(mid))lf = mid+1; else rt = mid - 1; } cout << fixed << setprecision(5) << (long double) 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:79:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:80:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...