Submission #1007581

# Submission time Handle Problem Language Result Execution time Memory
1007581 2024-06-25T08:09:05 Z c2zi6 Rice Hub (IOI11_ricehub) C++14
42 / 100
1000 ms 3928 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "ricehub.h"

int n;
VI a;
ll B;

int solve(int x, ll B) {
    int ret = 0;
    int r = upper_bound(all(a), x) - a.begin();
    int l = r-1;
    while (l >= 0 && r < n) {
        if (a[r]-x < x-a[l]) {
            if ((B -= a[r]-x) < 0) break;
            r++; 
            ret++;
        } else {
            if ((B -= x-a[l]) < 0) break;
            l--;
            ret++;
        }
    }
    while (r < n) {
        if ((B -= a[r]-x) < 0) break;
        r++; 
        ret++;
    }
    while (l >= 0) {
        if ((B -= x-a[l]) < 0) break;
        l--;
        ret++;
    }
    return ret;
}

int besthub(int R, int L, int X[], ll BVAL) {
    n = R;
    a = VI(n);
    B = BVAL;
    rep(i, n) a[i] = X[i];

    int ans = 0;
    replr(x, 0, L) setmax(ans, solve(x, B));
    return ans;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 452 KB Output is correct
17 Correct 1 ms 448 KB Output is correct
18 Correct 0 ms 448 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 4 ms 452 KB Output is correct
24 Correct 8 ms 348 KB Output is correct
25 Correct 10 ms 348 KB Output is correct
26 Correct 11 ms 344 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 725 ms 432 KB Output is correct
4 Correct 624 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 10 ms 460 KB Output is correct
14 Correct 9 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 19 ms 456 KB Output is correct
18 Correct 19 ms 348 KB Output is correct
19 Execution timed out 1008 ms 440 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 600 KB Output is correct
2 Correct 13 ms 604 KB Output is correct
3 Execution timed out 1020 ms 3928 KB Time limit exceeded
4 Halted 0 ms 0 KB -