Submission #460477

#TimeUsernameProblemLanguageResultExecution timeMemory
460477fuad27Rice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; int besthub(int r, int l, int x[], long long b) { int MAX = 0; for(int i = 1;i<r;i++) { int c = 0; long long cost = 0; int p1 = 0, p2 = MAX-1 while(p1 < r and p2 <= r) { if(cost <= b) { c = max(p2 - p1, c); p2++; if(p2 <= r) cost+=abs(x[p2-1] - x[i]); } else { cost-=abs(x[p1]-x[i]); p1++; } } MAX = max(c, MAX); } return MAX; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:10:3: error: expected ',' or ';' before 'while'
   10 |   while(p1 < r and p2 <= r) {
      |   ^~~~~
ricehub.cpp:8:13: warning: unused variable 'cost' [-Wunused-variable]
    8 |   long long cost = 0;
      |             ^~~~
ricehub.cpp:9:7: warning: unused variable 'p1' [-Wunused-variable]
    9 |   int p1 = 0, p2 = MAX-1
      |       ^~
ricehub.cpp:9:15: warning: unused variable 'p2' [-Wunused-variable]
    9 |   int p1 = 0, p2 = MAX-1
      |               ^~