Submission #679096

# Submission time Handle Problem Language Result Execution time Memory
679096 2023-01-07T12:29:55 Z jiahng Rice Hub (IOI11_ricehub) C++14
100 / 100
14 ms 3276 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 200010
#define INF (ll)1e9
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;


int R,L;
ll B;
long long ss[maxn],X[maxn];
bool pos(int x){
    FOR(i,1,R+1-x){
        // [i, i+x-1]
        int med = i+(x-1)/2;
        ll cost = X[med] * (med-i+1) - (ss[med] - ss[i-1]);
        cost += (ss[i+x-1] - ss[med]) - X[med]*(i+x-1-med);
        if (cost <= B) return 1;
    }
    return 0;
}
int besthub(int R, int L, int X[], long long B){
    ::R = R; ::L = L; ::B = B;
    FOR(i,1,R) ss[i] = ss[i-1] + X[i-1];
    FOR(i,1,R) ::X[i] = X[i-1];
    int l = 1, r = R+1;
    while (l + 1 < r){
        int m = (l + r) / 2;
        if (pos(m)) l = m;
        else r = m;
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 1 ms 316 KB Output is correct
23 Correct 1 ms 352 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 12 ms 3276 KB Output is correct
4 Correct 11 ms 3256 KB Output is correct
5 Correct 6 ms 1620 KB Output is correct
6 Correct 5 ms 1620 KB Output is correct
7 Correct 10 ms 3040 KB Output is correct
8 Correct 10 ms 3040 KB Output is correct
9 Correct 5 ms 1492 KB Output is correct
10 Correct 6 ms 1468 KB Output is correct
11 Correct 12 ms 3276 KB Output is correct
12 Correct 14 ms 3244 KB Output is correct
13 Correct 6 ms 1620 KB Output is correct
14 Correct 9 ms 1584 KB Output is correct
15 Correct 14 ms 2464 KB Output is correct
16 Correct 11 ms 2480 KB Output is correct
17 Correct 10 ms 2996 KB Output is correct
18 Correct 11 ms 2956 KB Output is correct
19 Correct 10 ms 3124 KB Output is correct
20 Correct 13 ms 3080 KB Output is correct