Submission #904983

# Submission time Handle Problem Language Result Execution time Memory
904983 2024-01-12T12:28:47 Z Macker Rice Hub (IOI11_ricehub) C++14
0 / 100
12 ms 4528 KB
#include "ricehub.h"
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")

vector<ll> v;
ll b, n;

bool can(int k){
    ll med = v[k / 2];
    ll dst = 0;
    for (int i = 0; i < k / 2; i++) {
        dst += med - v[i];
    }
    for (int i = k / 2; i < k; i++) {
        dst += v[i] - med;
    }
    
    if(dst <= b) return true;
    
    ll lmed = med;
    for (int i = k; i < n; i++) {
        med = v[(i + i - k + 1) / 2];

        dst -= med - v[i - k];
        dst += v[i] - lmed;

        if(dst <= b) return true;
        lmed = med;
    }
    return false;
}

int besthub(int R, int L, int X[], long long B)
{
    v.assign(X, X+R);
    b = B;
    n = R;
    int l = 0, r = R, mid;
    while(l < r){
        mid = (l + r + 1) / 2;
        if(can(mid)) l = mid;
        else r = mid - 1;
    }
    return l;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 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 1 ms 344 KB Output is correct
4 Correct 0 ms 348 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 344 KB Output is correct
8 Correct 1 ms 344 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 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 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 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 12 ms 3416 KB Output is correct
4 Correct 10 ms 4528 KB Output is correct
5 Correct 6 ms 3384 KB Output is correct
6 Correct 6 ms 3164 KB Output is correct
7 Correct 10 ms 4188 KB Output is correct
8 Correct 10 ms 4212 KB Output is correct
9 Correct 7 ms 3164 KB Output is correct
10 Correct 5 ms 3164 KB Output is correct
11 Correct 11 ms 4444 KB Output is correct
12 Correct 11 ms 4444 KB Output is correct
13 Incorrect 6 ms 3420 KB Output isn't correct
14 Halted 0 ms 0 KB -