Submission #224590

#TimeUsernameProblemLanguageResultExecution timeMemory
224590my99nRice Hub (IOI11_ricehub)C++14
0 / 100
9 ms640 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; }

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;
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...