답안 #104423

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104423 2019-04-06T18:17:51 Z dfistric 쌀 창고 (IOI11_ricehub) C++14
0 / 100
16 ms 1792 KB
#include <bits/stdc++.h>
#include "ricehub.h"

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ll long long

using namespace std;

int besthub(int n, int L, int arr[], ll B) {
    int r = 1, m = 0;
    int a = 1, b = 0;
    ll sum = 0;
    int ma = 0;
    REP(l, n) {
        while (r < n) {
            //cout << l << " " << r << " " << m << " " << a << " " << b << " " << sum << endl;
            int rr = r + 1, aa = a, bb = b + 1;
            int mm = (rr + l) / 2;
            ll sum2 = sum + (arr[r] - arr[m]);
            
            if (mm > m) {
                sum2 = sum2 - bb * (arr[mm] - arr[m]) + aa * (arr[mm] - arr[m]);
                aa++;
                bb--;
            }

            if (sum2 <= B) {
                sum = sum2, r = rr, a = aa, b = bb, m = mm;
            } else {
                break;
            }
        }
        //cout << l << " " << r << " " << m << " " << a << " " << b << " " << sum << endl << endl;
        ma = max(ma, r - l);
        a--, sum -= (arr[m] - arr[l]);
    }

    return ma;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Incorrect 2 ms 256 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 412 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 256 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 6 ms 512 KB Output is correct
3 Correct 16 ms 1792 KB Output is correct
4 Correct 15 ms 1792 KB Output is correct
5 Incorrect 9 ms 896 KB Output isn't correct
6 Halted 0 ms 0 KB -