Submission #348685

#TimeUsernameProblemLanguageResultExecution timeMemory
348685idk321Rice Hub (IOI11_ricehub)C++11
Compilation error
0 ms0 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100005; int pos[N]; ll sum[N]; int n; long long money; bool poss(int len) { ll cost = 0; int a = 0; int b = len - 1; int mid = (a + b) / 2; //cout << len << " " << cost << " " << money << endl; while (b < n) { cost = 0; if (a != mid) cost -= sum[mid - 1]; if (a != 0) sum += sum[a - 1]; sum += sum[b]; sum -= sum[mid]; mid++; a++; b++; if (cost <= money) return true; } return false; } int binarySearch() { int a = 1; int b = n; int res = -1; while (a <= b) { int mid = (a + b) / 2; if (poss(mid)) { res = mid; a = mid + 1; } else { b = mid - 1; } } return res; } int besthub(int n1, int l, int x[], long long money1) { money = money1; n = n1; for (int i = 0; i < n; i++) { pos[i] = x[i]; } for (int i = 0; i < n; i++) { sum[i] += pos[i]; if (i != 0) sum[i] += sum[i - 1]; } return binarySearch(); }

Compilation message (stderr)

ricehub.cpp: In function 'bool poss(int)':
ricehub.cpp:28:37: error: incompatible types in assignment of 'll' {aka 'long long int'} to 'll [100005]' {aka 'long long int [100005]'}
   28 |         if (a != 0) sum += sum[a - 1];
      |                                     ^
ricehub.cpp:29:21: error: incompatible types in assignment of 'll' {aka 'long long int'} to 'll [100005]' {aka 'long long int [100005]'}
   29 |         sum += sum[b];
      |                     ^
ricehub.cpp:30:23: error: incompatible types in assignment of 'll' {aka 'long long int'} to 'll [100005]' {aka 'long long int [100005]'}
   30 |         sum -= sum[mid];
      |                       ^