Submission #1007583

# Submission time Handle Problem Language Result Execution time Memory
1007583 2024-06-25T08:10:11 Z c2zi6 Rice Hub (IOI11_ricehub) C++14
68 / 100
1000 ms 2824 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;
    rep(i, n) setmax(ans, solve(a[i], B));
    return ans;
}



# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 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 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 2 ms 460 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 44 ms 512 KB Output is correct
24 Correct 21 ms 348 KB Output is correct
25 Correct 70 ms 344 KB Output is correct
26 Correct 81 ms 484 KB Output is correct
27 Correct 16 ms 348 KB Output is correct
28 Correct 16 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 604 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Execution timed out 1097 ms 2824 KB Time limit exceeded
4 Halted 0 ms 0 KB -