Submission #97379

#TimeUsernameProblemLanguageResultExecution timeMemory
97379Shafin666Rice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 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(ll r, ll l, ll x[], ll b) { ll answer = 0; ll inf = 1e9+7; //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)); v.pb(inf); ll maxlen = 0; ll k = 0, s = 0; for(ll i = 0; i < r+1; i++) { if(s + v[i] <= b) { s += v[i]; k++; } else if(v[i] > b) { maxlen = max(maxlen, k); s = 0; k = 0; } else { maxlen = max(maxlen, k); s = v[i]; k = 1; } } c = x[r/2+1]; v.clear(); for(ll i = 0; i < r; i++) v.pb(abs(x[i]-c)); v.pb(inf); k = 0, s = 0; for(ll i = 0; i < r+1; i++) { if(s + v[i] <= b) { s += v[i]; k++; } else if(v[i] > b) { maxlen = max(maxlen, k); s = 0; k = 0; } else { maxlen = max(maxlen, k); s = v[i]; k = 1; } } return maxlen; } /* ll main() { ll x[6] = {1, 2, 10, 12, 14}; cout << besthub(5, 20, x, 6) << endl; return 0; }*/

Compilation message (stderr)

ricehub.cpp: In function 'll besthub(ll, ll, ll*, ll)':
ricehub.cpp:12:5: warning: unused variable 'answer' [-Wunused-variable]
  ll answer = 0;
     ^~~~~~
/tmp/ccw0TVoo.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status