Submission #471104

# Submission time Handle Problem Language Result Execution time Memory
471104 2021-09-07T05:59:52 Z Killer2501 Sure Bet (CEOI17_sure) C++14
Compilation error
0 ms 0 KB
#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;
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;
}
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(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

sure.cpp: In function 'void add(long long int, long long int)':
sure.cpp:30:30: error: 'fe' was not declared in this scope; did you mean 'se'?
   30 |     for(; id; id -= id & -id)fe[id] = max(fe[id], x);
      |                              ^~
      |                              se
sure.cpp: In function 'long long int get(long long int)':
sure.cpp:35:54: error: 'fe' was not declared in this scope; did you mean 'se'?
   35 |     for(; id <= n; id += id & -id)total = max(total, fe[id]);
      |                                                      ^~
      |                                                      se
sure.cpp: In function 'int main()':
sure.cpp:82:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |        freopen(task".in", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:83:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |        freopen(task".out", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~