Submission #97382

#TimeUsernameProblemLanguageResultExecution timeMemory
97382Shafin666Rice Hub (IOI11_ricehub)C++14
0 / 100
27 ms3056 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<ll, ll> #define to second #define cost first typedef long long ll; typedef long double ld; using namespace std; ll besthub(int r, int l, int x[], ll b) { ll answer = 0; ll inf = 1e9+7, maxlen = -1; //sort(x, x+r); ll c = x[r/2]; vector<ll> v; for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c)); ll substart = 0, subend = 0; ll sum = 0; for(ll i = 0; i < r; i++) { sum += v[i]; subend++; while(sum > b) { sum -= v[substart++]; } maxlen = max(maxlen, subend-substart); } if(r<3) return maxlen; c = x[(r+1)/2]; v.clear(); for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c)); substart = 0, subend = 0; sum = 0; for(ll i = 0; i < r; i++) { sum += v[i]; subend++; while(sum > b) { sum -= v[substart++]; } maxlen = max(maxlen, subend-substart); } return maxlen; } /* int main() { int x[1] = {1}; cout << besthub(1, 20, x, 6) << endl; return 0; }*/

Compilation message (stderr)

ricehub.cpp: In function 'll besthub(int, int, int*, ll)':
ricehub.cpp:12:5: warning: unused variable 'answer' [-Wunused-variable]
  ll answer = 0;
     ^~~~~~
ricehub.cpp:13:5: warning: unused variable 'inf' [-Wunused-variable]
  ll inf = 1e9+7, maxlen = -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...