Submission #655498

#TimeUsernameProblemLanguageResultExecution timeMemory
655498PanTkdRice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <cmath> typedef long long ll; using namespace std; #define MAX_R 1000000 static int R, L; static long long B; static int X[MAX_R]; static int solution; inline void my_assert(int e) {if (!e) abort();} int besthub(int R, int L, int X[], long long B) { for(ll i = R;i>=1;i--){ ll cost = 0; ll med = ((i)/2); //cout<<i<<"----\n"; for(ll j = 0;j<i;j++){ cost += abs(X[med]-X[j]); } if(cost<=B){ return i;} for(ll j = 1;j<=R-i;j++){ //cout<<cost<<endl; med++; cost += abs(i/2)*(X[med]-X[med-1]); //cout<<cost<<endl; cost -= abs((i-1)/2)*(X[med]-X[med-1]); //cout<<cost<<endl; cost += abs(X[med]-X[j+i-1]); //cout<<cost<<endl; cost -= abs(X[med-1]-X[j-1]); //cout<<cost<<"\n\n\n"; //med+=2; if(cost<=B){return i;} } } return 1; } static void read_input() { int i; my_assert(3==scanf("%d %d %lld",&R,&L,&B)); for(i=0; i<R; i++) my_assert(1==scanf("%d",&X[i])); } int main() { int ans; read_input(); ans = besthub(R,L,X,B); cout<<ans<<endl; return 0; } /* 5 20 6 1 2 10 12 14 */

Compilation message (stderr)

ricehub.cpp:11:12: warning: 'solution' defined but not used [-Wunused-variable]
   11 | static int solution;
      |            ^~~~~~~~
/usr/bin/ld: /tmp/cc5KDVuB.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjRQmey.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status