Submission #471105

# Submission time Handle Problem Language Result Execution time Memory
471105 2021-09-07T06:00:31 Z Killer2501 Sure Bet (CEOI17_sure) Java 11
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, 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

sure.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
sure.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
sure.java:2: error: illegal character: '#'
#define ll long long
^
sure.java:3: error: illegal character: '#'
#define ld long double
^
sure.java:4: error: illegal character: '#'
#define pb push_back
^
sure.java:5: error: illegal character: '#'
#define task "tests"
^
sure.java:6: error: illegal character: '#'
#define pll pair<ll, ll>
^
sure.java:7: error: illegal character: '#'
#define pi pair<ll, pll>
^
sure.java:8: error: illegal character: '#'
#define fi first
^
sure.java:9: error: illegal character: '#'
#define se second
^
sure.java:12: error: class, interface, or enum expected
const ll mod = 1000000000;
^
sure.java:13: error: class, interface, or enum expected
const ll N = 1e5+55;
^
sure.java:14: error: class, interface, or enum expected
const int base = 313;
^
sure.java:15: error: class, interface, or enum expected
ll n, m, t, k, T, ans, q, tong;
^
sure.java:16: error: class, interface, or enum expected
ll a[N], b[N], d[N];
^
sure.java:17: error: class, interface, or enum expected
vector<ll> adj[N], kq;
^
sure.java:18: error: class, interface, or enum expected
ll pw(ll k, ll n)
^
sure.java:21: error: class, interface, or enum expected
    for(; n; n >>= 1)
    ^
sure.java:21: error: class, interface, or enum expected
    for(; n; n >>= 1)
          ^
sure.java:21: error: class, interface, or enum expected
    for(; n; n >>= 1)
             ^
sure.java:24: error: class, interface, or enum expected
        k = k * k % mod;
        ^
sure.java:25: error: class, interface, or enum expected
    }
    ^
sure.java:27: error: class, interface, or enum expected
}
^
sure.java:32: error: class, interface, or enum expected
}
^
sure.java:36: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
    ^
sure.java:36: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
                   ^
sure.java:36: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
                           ^
sure.java:39: error: class, interface, or enum expected
        ll j = min(n, (total - x) / mod);
        ^
sure.java:40: error: class, interface, or enum expected
        if(j < 0)continue;
        ^
sure.java:41: error: class, interface, or enum expected
        if(d[j] - mod * i >= x)return true;
        ^
sure.java:42: error: class, interface, or enum expected
    }
    ^
sure.java:44: error: class, interface, or enum expected
}
^
sure.java:48: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
    ^
sure.java:48: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
                   ^
sure.java:48: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)
                           ^
sure.java:51: error: class, interface, or enum expected
        cin >> x;
        ^
sure.java:52: error: class, interface, or enum expected
        a[i] = mod * x;
        ^
sure.java:53: error: class, interface, or enum expected
        cin >> x;
        ^
sure.java:54: error: class, interface, or enum expected
        b[i] = mod * x;
        ^
sure.java:55: error: class, interface, or enum expected
    }
    ^
sure.java:57: error: class, interface, or enum expected
    sort(b+1, b+1+n, cmp);
    ^
sure.java:58: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)d[i] = max(d[i-1], d[i-1] + a[i] - mod);
    ^
sure.java:58: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)d[i] = max(d[i-1], d[i-1] + a[i] - mod);
                   ^
sure.java:58: error: class, interface, or enum expected
    for(int i = 1; i <= n; i ++)d[i] = max(d[i-1], d[i-1] + a[i] - mod);
                           ^
sure.java:59: error: class, interface, or enum expected
    ll lf = 0, rt = mod * mod, mid;
    ^
sure.java:61: error: class, interface, or enum expected
    while(lf <= rt)
    ^
sure.java:64: error: class, interface, or enum expected
        if(check(mid))lf = mid+1;
        ^
sure.java:65: error: class, interface, or enum expected
        else rt = mid - 1;
        ^
sure.java:66: error: class, interface, or enum expected
    }
    ^
sure.java:68: error: class, interface, or enum expected
}
^
sure.java:74: error: class, interface, or enum expected
       freopen(task".out", "w", stdout);
       ^
sure.java:75: error: class, interface, or enum expected
    }
    ^
sure.java:77: error: class, interface, or enum expected
    cin.tie(0);
    ^
sure.java:78: error: class, interface, or enum expected
    cout.tie(0);
    ^
sure.java:79: error: class, interface, or enum expected
    int ntest = 1;
    ^
sure.java:81: error: class, interface, or enum expected
    while(ntest -- > 0)
    ^
sure.java:83: error: class, interface, or enum expected
}
^
57 errors