답안 #788771

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
788771 2023-07-20T15:01:16 Z Ronin13 쌀 창고 (IOI11_ricehub) C++17
17 / 100
16 ms 1676 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define ll long long 
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int, int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

int besthub(int n, int l, int X[], long long B){
      ll pref[n + 1];
      pref[0] = 0;
      for(int i = 1; i <= n; i++){
          pref[i] = pref[i - 1] + (ll)X[i - 1];
      }
      
      int mx = 0;
      for(int i = 1; i <= n; i++){
          int l = 0, r = n;
          while(l + 1 < r){
              int mid = (l + r) / 2;
              int x = (mid + 1) / 2;
              int y = mid - x;
              if(i < x) {
                  r = mid;
                  continue;
              } 
              if(i + y > n){
                  r = mid;
                  continue;
              }
              ll a = (ll)x * (ll)X[i - 1] - (pref[i] - pref[i - x]);
              ll b = pref[i + y] - pref[i] - (ll)X[i - 1] * (ll)y;
              if(a + b <= B) l = mid;
              else r = mid;
          }
          //cout << l << ' ';
          mx = max(mx, l);
      }
      return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 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 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 576 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Incorrect 16 ms 1676 KB Output isn't correct
4 Halted 0 ms 0 KB -