답안 #402509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402509 2021-05-11T21:16:39 Z Lobo 쌀 창고 (IOI11_ricehub) C++17
0 / 100
4 ms 460 KB
#include <bits/stdc++.h>
#include <ricehub.h>

using namespace std;

const long long INFll = 1e18;
const int INFii = 1e9;
const long long mod = (long long) 1e9 + 7;
typedef long long ll;
typedef int ii;
typedef double dbl;
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back

#define maxn 110000
//LEMBRAR DE MUDAR

ll ps[maxn];

int besthub(int R, int L, int X[], long long B){
  
    ps[0] = 0;
    for(ii i = R; i >= 1; i--) {
        X[i] = X[i-1];
    }

    for(ii i = 1; i <= R; i++) {
        ps[i] = ps[i-1] + X[i]; 
    }

    ii ans = 0;
    for(ii i = 1; i <= R; i++) {
        ii l = i;
        ii r = R;
        ii mid = (l+r)/2;
        ii best = mid;

        while(l <= r) {
            ii m = (i+mid)/2;
            ii cost = X[m]*(m-i+1) - ps[m] + ps[i-1]  +  ps[mid] - ps[m] - X[i]*(mid-m);

            if(cost <= B) {
                best = mid;
                l = mid+1;
                mid = (l+r)/2;
            }
            else {
                r = mid-1;
                mid = (l+r)/2;
            }
        }

        ans = max(ans, best-i+1);

    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -