Submission #302644

#TimeUsernameProblemLanguageResultExecution timeMemory
302644errorgornRice Hub (IOI11_ricehub)C++17
100 / 100
20 ms1792 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se second #define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--)) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() int besthub(int n, int L, int arr[], long long k){ int m=0,r=-1; ll curr=0; int ans=0; rep(l,0,n){ if (m<l+r>>1){ curr-=(arr[m+1]-arr[m])*((r-m)-(m-l+1)); m++; } //cout<<l<<" "<<m<<" "<<r<<" "<<curr<<endl; while (curr<=k){ ans=max(ans,r-l+1); if (r==n-1) break; r++; curr+=arr[r]-arr[m]; if (m<l+r>>1){ curr-=(arr[m+1]-arr[m])*((r-m)-(m-l+1)); m++; } } curr-=arr[m]-arr[l]; } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:22:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |   if (m<l+r>>1){
      |         ~^~
ricehub.cpp:34:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |    if (m<l+r>>1){
      |          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...