답안 #592731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592731 2022-07-09T14:08:38 Z Mahtimursu 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 1208 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int besthub(int R, int L, int X[], long long B) {
    vector<ll> lft;
    vector<ll> rgt;

    int best = 0;

    int n = R;

    for (int i = n - 1; i > 0; --i) {
        rgt.push_back(X[i]);
    }

    for (int i = 0; i < n; ++i) {
        ll leftm = B;
        int cur = 0;

        int li = lft.size() - 1;
        int ri = 0;

        vector<ll> dst;

        for (int j = 0; j < n; ++j) dst.push_back(abs(X[i] - X[j]));

        sort(dst.begin(), dst.end());

        int idx = 0;
        while (idx < n && dst[idx] <= leftm) {
            leftm -= dst[idx++];
            cur++;
        }

        /*while (true) {
            ll leftd = li >= 0 ? abs(lft[li] - X[i]) : 1e18;
            ll rightd = ri < (int)rgt.size() ? abs(rgt[ri] - X[i]) : 1e18;

            if (min(leftd, rightd) > leftm) break;

            cur++;

            if (leftd < rightd) {
                leftm -= leftd;
                li--;
            } else {
                leftm -= rightd;
                ri++;
            }
        }*/

        best = max(best, cur);

        lft.push_back(X[i]);
        rgt.pop_back();
    }

    return best;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:24:13: warning: unused variable 'li' [-Wunused-variable]
   24 |         int li = lft.size() - 1;
      |             ^~
ricehub.cpp:25:13: warning: unused variable 'ri' [-Wunused-variable]
   25 |         int ri = 0;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 312 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 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 6 ms 212 KB Output is correct
24 Correct 5 ms 328 KB Output is correct
25 Correct 6 ms 324 KB Output is correct
26 Correct 5 ms 336 KB Output is correct
27 Correct 5 ms 212 KB Output is correct
28 Correct 6 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 23 ms 340 KB Output is correct
4 Correct 24 ms 340 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 3 ms 212 KB Output is correct
7 Correct 12 ms 340 KB Output is correct
8 Correct 11 ms 340 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 13 ms 340 KB Output is correct
12 Correct 13 ms 348 KB Output is correct
13 Correct 22 ms 348 KB Output is correct
14 Correct 23 ms 364 KB Output is correct
15 Correct 5 ms 212 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 14 ms 356 KB Output is correct
18 Correct 15 ms 360 KB Output is correct
19 Correct 21 ms 360 KB Output is correct
20 Correct 21 ms 356 KB Output is correct
21 Correct 356 ms 536 KB Output is correct
22 Correct 368 ms 684 KB Output is correct
23 Correct 727 ms 688 KB Output is correct
24 Correct 728 ms 600 KB Output is correct
25 Correct 686 ms 588 KB Output is correct
26 Correct 721 ms 548 KB Output is correct
27 Correct 619 ms 568 KB Output is correct
28 Correct 682 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 1208 KB Time limit exceeded
2 Halted 0 ms 0 KB -