답안 #1108124

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108124 2024-11-02T23:25:20 Z Gabriel 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 5200 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;
  if(n == 1) return 1;
  vector<long long> a(n);
  for(long long i = 0; i < n; i++){
     a[i] = X[i];
  }
  long long Mayor = 1;
  vector<long long> Distancias(n, 0);
  for(long long i = 0; i < n; i++){
    Distancias[i] = 0;
    for(long long j = i - 1; j > -1; j--){
      Distancias[j] = a[i] - a[j] + Distancias[j + 1];
    }
    for(long long j = i + 1; j < n; j++){
      Distancias[j] = a[j] - a[i] + Distancias[j - 1];
    }
    for(long long j = i; j > -1; j--){
      if(Distancias[j] > B) break;
      long long Tenemos = i - j + 1, Aun_hay = B - Distancias[j];
      long long Izquierda = i, Derecha = n - 1, Mejor = i;
      while(1){
        if(Izquierda >= (Derecha + 1)) break;
        long long Promedio = (Izquierda + Derecha) / 2;
        if(Distancias[Promedio] <= Aun_hay){
          Izquierda = Promedio + 1;
          Mejor = Promedio;
        } else Derecha = Promedio - 1;
      }
      Tenemos += Mejor - i;
      Mayor = max(Mayor, Tenemos);
    }
    for(long long j = i + 1; j < n; j++){
      if(Distancias[j] > B) break;
      long long Tenemos = j - i, Aun_hay = B - Distancias[j];
      long long Izquierda = 0, Derecha = i, Mejor = i;
      while(1){
        if(Izquierda >= (Derecha + 1)) break;
        long long Promedio = (Izquierda + Derecha) / 2;
        if(Distancias[Promedio] <= Aun_hay){
          Derecha = Promedio - 1;
          Mejor = Promedio;
        } else Izquierda = Promedio + 1;
      }
      Tenemos += i - Mejor + 1;
      Mayor = max(Mayor, Tenemos);
    }
  }
  return Mayor;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 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 336 KB Output is correct
6 Correct 1 ms 504 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 508 KB Output is correct
9 Correct 1 ms 508 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 336 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 508 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 508 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 2 ms 460 KB Output is correct
25 Correct 2 ms 336 KB Output is correct
26 Correct 3 ms 452 KB Output is correct
27 Correct 2 ms 628 KB Output is correct
28 Correct 2 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 7 ms 336 KB Output is correct
4 Correct 8 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 3 ms 472 KB Output is correct
8 Correct 3 ms 336 KB Output is correct
9 Correct 2 ms 336 KB Output is correct
10 Correct 2 ms 336 KB Output is correct
11 Correct 3 ms 640 KB Output is correct
12 Correct 2 ms 336 KB Output is correct
13 Correct 8 ms 336 KB Output is correct
14 Correct 8 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 5 ms 336 KB Output is correct
19 Correct 7 ms 336 KB Output is correct
20 Correct 8 ms 336 KB Output is correct
21 Correct 36 ms 336 KB Output is correct
22 Correct 36 ms 336 KB Output is correct
23 Correct 214 ms 336 KB Output is correct
24 Correct 205 ms 336 KB Output is correct
25 Correct 204 ms 336 KB Output is correct
26 Correct 220 ms 336 KB Output is correct
27 Correct 255 ms 336 KB Output is correct
28 Correct 254 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 260 ms 1096 KB Output is correct
2 Correct 247 ms 848 KB Output is correct
3 Execution timed out 1065 ms 5200 KB Time limit exceeded
4 Halted 0 ms 0 KB -