답안 #1110551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110551 2024-11-09T21:36:26 Z Gabriel 쌀 창고 (IOI11_ricehub) C++17
100 / 100
23 ms 5316 KB
#include "ricehub.h"
#include "bits/stdc++.h"
using namespace std;
int besthub(int R, int L, int X[], long long B){
  long long n = R;
  vector<long long> a, Suma;
  for(long long i = 0; i <= n; i++){
    a.push_back(X[i]);
    Suma.push_back(a.back());
    if(i > 0) Suma.back() += Suma[i - 1];
  }
  int Mejor = -2;
  long long Resta = 0;
  for(long long i = 0; i < n; i++){
    long long Izquierda = i, Derecha = n - 1, Tentativo = i;
    Resta += a[i];
    while(1){
      if(Izquierda >= (Derecha + 1)) break;
      long long Promedio = (Izquierda + Derecha) / 2;
      long long zd = (Promedio + i) / 2;
      long long Distancia = 0;
      Distancia += Suma[Promedio] - Suma[zd] - a[zd] * (Promedio - zd);
      if(zd > 0) Distancia -= Suma[zd - 1];
      if(i > 0) Distancia += Suma[i - 1];
      Distancia += a[zd] * (zd - i);
      //Distancia -= a[zd] * (Promedio - i + 1);
      if(Distancia <= B){
        Izquierda = Promedio + 1;
        Tentativo = Promedio;
      } else Derecha = Promedio - 1;
      //cout<<i<<" "<<Promedio<<" "<<Distancia<<"\n";
    }
    Mejor = max(Mejor, (int)(Tentativo - i + 1));
  }
  return Mejor;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 508 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 356 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 504 KB Output is correct
16 Correct 1 ms 500 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 504 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 504 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 592 KB Output is correct
22 Correct 1 ms 592 KB Output is correct
23 Correct 1 ms 592 KB Output is correct
24 Correct 1 ms 592 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 2 ms 592 KB Output is correct
27 Correct 1 ms 592 KB Output is correct
28 Correct 2 ms 592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1104 KB Output is correct
2 Correct 3 ms 1104 KB Output is correct
3 Correct 14 ms 4292 KB Output is correct
4 Correct 16 ms 5036 KB Output is correct
5 Correct 7 ms 3788 KB Output is correct
6 Correct 8 ms 3788 KB Output is correct
7 Correct 17 ms 5060 KB Output is correct
8 Correct 17 ms 5060 KB Output is correct
9 Correct 9 ms 3788 KB Output is correct
10 Correct 8 ms 3788 KB Output is correct
11 Correct 23 ms 5316 KB Output is correct
12 Correct 17 ms 5316 KB Output is correct
13 Correct 8 ms 4044 KB Output is correct
14 Correct 9 ms 3920 KB Output is correct
15 Correct 12 ms 5060 KB Output is correct
16 Correct 13 ms 5060 KB Output is correct
17 Correct 15 ms 5316 KB Output is correct
18 Correct 15 ms 5268 KB Output is correct
19 Correct 16 ms 5316 KB Output is correct
20 Correct 15 ms 5316 KB Output is correct