Submission #164831

#TimeUsernameProblemLanguageResultExecution timeMemory
164831arnold518Rice Hub (IOI11_ricehub)C++14
100 / 100
19 ms760 KiB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int R, L, *X, ans;
ll B;

int besthub(int _R, int _L, int *_X, ll _B)
{
    int i, j;
    R=_R; L=_L; X=_X; B=_B;

    ll S=0;
    for(i=0, j=0; i<R; i++)
    {
        while(S<=B && j<R) { j++; S+=X[j]-X[i+j>>1]; }
        S-=X[i+j+1>>1]-X[i];
        ans=max(ans, j-i);
    }
    return ans;
}

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, ll)':
ricehub.cpp:20:46: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         while(S<=B && j<R) { j++; S+=X[j]-X[i+j>>1]; }
                                             ~^~
ricehub.cpp:21:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         S-=X[i+j+1>>1]-X[i];
              ~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...