제출 #1236690

#제출 시각아이디문제언어결과실행 시간메모리
1236690JelaByteEngineerRice Hub (IOI11_ricehub)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "ricehub.h" using namespace std; #define ll long long bool ok (int mid, ll b, int n, vector <ll> &x, vector <ll> &pref) { //cout<<"mid je: "<<mid<<endl; for (int i=0; i<=n-mid; i++) { //cout<<"prvi je na poz: "<<i<<endl; ll prf=x[i+(mid/2)]; //cout<<"prosek prvih mid je: "<<prf<<endl; int up=upper_bound(x.begin(), x.end(), prf)-x.begin(); if (upper_bound(x.begin(), x.end(), prf)==x.end()) up=prf; //cout<<"up je: "<<up<<endl; //cout<<"budzet je: "<<-pref[up-1]*(up>0)+pref[i-1]*(i>0)+(up-i)*prf+pref[i+mid-1]-pref[up-1]-(mid-up+i)*prf<<endl; if ((up>0)? -pref[up-1]:0)+(i>0? pref[i-1]:0)+(up-i)*prf+pref[i+mid-1]-(up>0? pref[up-1]:0)-(mid-up+i)*prf<=b) return true; } return false; } int besthub (int R, int L, int X[], ll B) { int n=R; vector <ll> x(n); for (int i=0; i<n; i++) x[i]=X[i]; vector <ll> pref(n); for (int i=0; i<n; i++) pref[i]=pref[i-1]*(i>0)+x[i]; int l=1, r=n, ans=1; while (l<=r) { int mid=l+(r-l)/2; if (ok(mid, B, n, x, pref)) {ans=max(ans, mid); l=mid+1;} else r=mid-1; } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'bool ok(int, long long int, int, std::vector<long long int>&, std::vector<long long int>&)':
ricehub.cpp:17:118: error: expected ';' before ')' token
   17 |         if ((up>0)? -pref[up-1]:0)+(i>0? pref[i-1]:0)+(up-i)*prf+pref[i+mid-1]-(up>0? pref[up-1]:0)-(mid-up+i)*prf<=b) return true;
      |                                                                                                                      ^
      |                                                                                                                      ;