답안 #471094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
471094 2021-09-07T05:40:15 Z Killer2501 Sure Bet (CEOI17_sure) C++14
0 / 100
2 ms 2636 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 = 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(c[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 ++)c[i] = max(c[i-1], c[i-1] + 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

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);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -