Submission #542676

# Submission time Handle Problem Language Result Execution time Memory
542676 2022-03-27T13:26:56 Z neki Rice Hub (IOI11_ricehub) C++14
100 / 100
15 ms 3340 KB
#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define par pair<ll, ll>
#define ld long double
#define mod 998244353
 
int besthub(int n, int L, int X[], ll B){
    vc<ll> x(n+1, 0);
    loop(i, 0, n) x[i+1]=X[i];
    
    vc<ll> pr=x;
    loop(i, 1, n+1) pr[i]+=pr[i-1];
    
    function<ll (ll, ll)> query=[&](ll l, ll r){
        return pr[r] - pr[l-1];
    };
    function<ll (ll, ll)> cost=[&](ll l, ll r){
        ll mid=(l+r)/2;
        
        ll ret=0;
        if(l<mid) ret+=(mid-l) * x[mid] - query(l, mid-1);
        if(mid<r) ret+=query(mid+1, r) - (r-mid) * x[mid];
        return ret;
    };
    
    ll r=1, ans=0;
    loop(l, 1, n+1){
        while(r+1<=n and cost(l, r+1)<=(ll)B) ++r;
        ans=max(ans, r-l+1);
    }
    
    return (int)ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 316 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 224 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 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 316 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 1 ms 212 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 212 KB Output is correct
4 Correct 1 ms 212 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 288 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 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 340 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 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 348 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 852 KB Output is correct
2 Correct 3 ms 808 KB Output is correct
3 Correct 13 ms 3236 KB Output is correct
4 Correct 13 ms 3276 KB Output is correct
5 Correct 7 ms 1620 KB Output is correct
6 Correct 6 ms 1608 KB Output is correct
7 Correct 12 ms 2984 KB Output is correct
8 Correct 12 ms 3028 KB Output is correct
9 Correct 7 ms 1576 KB Output is correct
10 Correct 7 ms 1584 KB Output is correct
11 Correct 13 ms 3340 KB Output is correct
12 Correct 13 ms 3284 KB Output is correct
13 Correct 7 ms 1620 KB Output is correct
14 Correct 7 ms 1632 KB Output is correct
15 Correct 15 ms 2476 KB Output is correct
16 Correct 10 ms 2476 KB Output is correct
17 Correct 11 ms 2988 KB Output is correct
18 Correct 11 ms 2872 KB Output is correct
19 Correct 12 ms 3068 KB Output is correct
20 Correct 14 ms 3156 KB Output is correct