Submission #319707

# Submission time Handle Problem Language Result Execution time Memory
319707 2020-11-06T08:23:28 Z neki Rice Hub (IOI11_ricehub) C++14
100 / 100
20 ms 2540 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long 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 sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#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 mn 100100
#define pa pair<ll, ll>
#define ld long double 
ll pref[mn];
ll cl(ll l, ll r, ll c){
    return (pref[r] - pref[c]) - (pref[c-1]-pref[l-1]);
}
ll cs(ll l, ll r, ll c){
    return (pref[r] - pref[c]) - (pref[c]-pref[l-1]);
}
int besthub(int r, int l,int x[], ll b){
    loop(i, 0, r) pref[i+1]=pref[i]+x[i];
    ll lf=1, ans=0;
    loop(i, 1, r+1){
        if(lf<i and 2 * i - lf>r or cl(lf, 2 * i - lf, i)>b) lf++;
        ans=max(ans, 2 * (i- lf) +1);
    }
    lf=1;
    loop(i, 1, r){
        if(lf<i and 2 * i - lf + 1>r or cs(lf, 2 * i - lf + 1, i)>b) lf++;
        ans=max(ans, 2 * (i- lf+1));
    }
    return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   34 |         if(lf<i and 2 * i - lf>r or cl(lf, 2 * i - lf, i)>b) lf++;
      |            ~~~~~^~~~~~~~~~~~~~~~
ricehub.cpp:39:17: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   39 |         if(lf<i and 2 * i - lf + 1>r or cs(lf, 2 * i - lf + 1, i)>b) lf++;
      |            ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 396 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 492 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 492 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 748 KB Output is correct
2 Correct 3 ms 748 KB Output is correct
3 Correct 17 ms 2540 KB Output is correct
4 Correct 17 ms 2540 KB Output is correct
5 Correct 7 ms 1260 KB Output is correct
6 Correct 8 ms 1260 KB Output is correct
7 Correct 15 ms 2284 KB Output is correct
8 Correct 15 ms 2284 KB Output is correct
9 Correct 7 ms 1260 KB Output is correct
10 Correct 7 ms 1260 KB Output is correct
11 Correct 17 ms 2540 KB Output is correct
12 Correct 17 ms 2540 KB Output is correct
13 Correct 8 ms 1260 KB Output is correct
14 Correct 8 ms 1260 KB Output is correct
15 Correct 12 ms 2028 KB Output is correct
16 Correct 12 ms 2028 KB Output is correct
17 Correct 15 ms 2284 KB Output is correct
18 Correct 20 ms 2284 KB Output is correct
19 Correct 17 ms 2540 KB Output is correct
20 Correct 16 ms 2412 KB Output is correct