답안 #742076

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
742076 2023-05-15T14:46:28 Z PagodePaiva 쌀 창고 (IOI11_ricehub) C++14
0 / 100
2 ms 468 KB
#include<bits/stdc++.h>
#include "ricehub.h"

using namespace std;

int besthub(int R, int L, int X[], long long B){
  int n = R, M = L;
  int v[n];

  for(int i = 0;i < n;i++){
    v[i] = X[i];
  }

  int b = B;

  int l = 1, r = n;

  int pref[n];
  pref[0] = 0;

  for(int i = 0;i < n;i++){
    pref[i+1] = pref[i] + v[i];
  }

  while(l < r){
    int mid = (l+r)/2;
    int t = mid/2;
    bool aux = true;
    for(int i = 0;i < n-mid+1;i++){
      int p = v[i + t];
      // int val = pref[i+mid-1] - pref[i+t];
      int val = pref[i+mid] - pref[i+t] + pref[i] - pref[i+t];
      if(val <= b){
        l = mid+1;
        aux = false;
        break;
      }
    }

    if(aux){
      r = mid;
    }
  }

  return l;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:30:11: warning: unused variable 'p' [-Wunused-variable]
   30 |       int p = v[i + t];
      |           ^
ricehub.cpp:7:14: warning: unused variable 'M' [-Wunused-variable]
    7 |   int n = R, M = L;
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -