Submission #224588

#TimeUsernameProblemLanguageResultExecution timeMemory
224588my99nRice Hub (IOI11_ricehub)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; long long s[100100]; int sum(int l, int r) { if (l == 0) return s[r]; return s[r] - s[l - 1]; } int besthub(int n, int L, int x[], long long b) { s[0] = x[0]; for (int i = 1; i < n; i++) s[i] = 0; for (int i = 1; i < n; i++) s[i] = x[i] + s[i - 1]; int l = 0, r = 0, ans = 1; for (int i = 0; i < n; i++) { int l = 0, r = n - 1; while (l < r) { int mid = (l + r) / 2; int med = (i + mid) / 2; int left = s[med] * (med - i + 1) - sum(i, med); int right = sum(med + 1, mid) - s[med] * (mid - med); if (left + right > b) r = mid; else l = mid + 1; } ans = max(ans, l - i + 1); } return ans; } int main() { int n, l, b; scanf("%d %d %d", &n, &l, &b); int x[n]; for (int i = 0; i < n; i++) scanf("%d", &x[i]); printf("%d", besthub(n, l, x, b)); }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:16:9: warning: unused variable 'l' [-Wunused-variable]
     int l = 0, r = 0, ans = 1;
         ^
ricehub.cpp:16:16: warning: unused variable 'r' [-Wunused-variable]
     int l = 0, r = 0, ans = 1;
                ^
ricehub.cpp: In function 'int main()':
ricehub.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d", &n, &l, &b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ricehub.cpp:39:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 0; i < n; i++) scanf("%d", &x[i]);
                                 ~~~~~^~~~~~~~~~~~~
/tmp/ccZqNY3u.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccdzkxrg.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status