제출 #677577

#제출 시각아이디문제언어결과실행 시간메모리
677577ThegeekKnight16Rice Hub (IOI11_ricehub)C++17
0 / 100
2 ms596 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; const int MAXN = 1e5 + 10; long long X[MAXN], SX[MAXN]; bool Teste(int R, int L, long long B, int tam) { for (int l = 1, r = tam; r <= R; l++, r++) { int m = (l + r) / 2; long long sum = ((m - l + 1) * X[m]) - (SX[m] - SX[l-1]); sum += (SX[r] - SX[m]) - ((r - m) * SX[m]); if (sum <= B) return true; } return false; } int besthub(int R, int L, int _X[], long long B) { for (int i = 1; i <= R; i++) X[i] = (long long)(_X[i-1]); for (int i = 1; i <= R; i++) SX[i] = X[i] + SX[i-1]; int ini = 1; int fim = R; while (ini < fim) { int m = (ini + fim) / 2; if (ini == fim-1) m = fim; if (Teste(R, L, B, m)) ini = m; else fim = m-1; } return ini; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...