Submission #1036290

# Submission time Handle Problem Language Result Execution time Memory
1036290 2024-07-27T08:15:27 Z trucmai A Difficult(y) Choice (BOI21_books) C++17
45 / 100
5 ms 8276 KB
#include "books.h"
#include <bits/stdc++.h>
#ifdef LOCAL
#include "/home/trcmai/code/tools.h"
#define debug(x...)                                                           \
    cerr << "\e[91m" << __func__ << ":" << __LINE__ << " [" << #x << "] = ["; \
    _print(x);                                                                \
    cerr << "\e[39m" << endl;
#else
#define debug(x...)
#endif
using namespace std;
#define all(a) a.begin(), a.end()
#define ll long long
#define endl '\n'
const int N = 1e6 + 6, LOG = 27, MOD = 1e9 + 7;
const ll INF = 1e18;

ll a[N];
ll ask(int i)
{
    if (a[i] != -1)
        return a[i];
    else
        return a[i] = skim(i);
}
void solve(int N, int K, long long A, int S)
{
    memset(a, -1, sizeof(a));
    int l = 1, r = N - K + 1;
    // Check xem ton tai doan lien tiep nao thoa man khong
    while (l <= r) {
        int m = (r + l) >> 1;
        ll sum = 0;
        for (int i = m; i <= m + K - 1; ++i) {
            sum += ask(i);
        }
        if (sum >= A && sum <= 2 * A) {
            vector<int> res;
            for (int i = m; i <= m + K - 1; ++i)
                res.emplace_back(i);
            answer(res);
        }
        if (sum < A)
            l = m + 1;
        if (sum > 2 * A)
            r = m - 1;
    }
    // Neu khong ton tai, check xem doan [1,k - 1] co ghep duoc voi vi tri ith thoa man khong
    l = K, r = N - K + 1;
    int pos = -1;
    while (l <= r) {
        int m = (r + l) >> 1;
        ll val = ask(m);
        if (val >= A) {
            pos = m;
            r = m - 1;
        } else
            l = m + 1;
    }
    if (pos != -1) {
        vector<int> res;
        ll sum = ask(pos);
        for (int i = 1; i <= K - 1; ++i) {
            sum += ask(i);
        }
        if (sum >= A && sum <= 2 * A) {
            for (int i = 1; i <= K - 1; ++i)
                res.emplace_back(i);
            res.emplace_back(pos);
            answer(res);
        }
    }
    impossible();
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8064 KB Output is correct
3 Correct 3 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 3 ms 8024 KB Output is correct
6 Correct 3 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 3 ms 8024 KB Output is correct
3 Correct 3 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 3 ms 8024 KB Output is correct
6 Correct 3 ms 8192 KB Output is correct
7 Correct 3 ms 8172 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 3 ms 8024 KB Output is correct
10 Correct 3 ms 8024 KB Output is correct
11 Correct 3 ms 8024 KB Output is correct
12 Correct 4 ms 8024 KB Output is correct
13 Correct 4 ms 8024 KB Output is correct
14 Correct 4 ms 8024 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 5 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 5 ms 8024 KB Output is correct
3 Correct 4 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 4 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 5 ms 8024 KB Output is correct
3 Correct 4 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 4 ms 8024 KB Output is correct
10 Correct 4 ms 8024 KB Output is correct
11 Correct 3 ms 8276 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 4 ms 8024 KB Output is correct
14 Correct 4 ms 8024 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 4 ms 8024 KB Output is correct
18 Correct 4 ms 8024 KB Output is correct
19 Correct 3 ms 8020 KB Output is correct
20 Correct 3 ms 8024 KB Output is correct
21 Correct 4 ms 8024 KB Output is correct
22 Correct 4 ms 8024 KB Output is correct
23 Correct 4 ms 8024 KB Output is correct
24 Correct 4 ms 8024 KB Output is correct
25 Correct 4 ms 8024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 5 ms 8024 KB Output is correct
3 Correct 4 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 4 ms 8024 KB Output is correct
10 Correct 4 ms 8024 KB Output is correct
11 Correct 3 ms 8276 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 4 ms 8024 KB Output is correct
14 Correct 4 ms 8024 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 4 ms 8024 KB Output is correct
18 Correct 4 ms 8024 KB Output is correct
19 Correct 3 ms 8020 KB Output is correct
20 Correct 3 ms 8024 KB Output is correct
21 Correct 4 ms 8024 KB Output is correct
22 Correct 4 ms 8024 KB Output is correct
23 Correct 4 ms 8024 KB Output is correct
24 Correct 4 ms 8024 KB Output is correct
25 Correct 4 ms 8024 KB Output is correct
26 Correct 3 ms 8024 KB Output is correct
27 Correct 3 ms 8092 KB Output is correct
28 Correct 3 ms 8024 KB Output is correct
29 Correct 4 ms 8024 KB Output is correct
30 Correct 4 ms 8088 KB Output is correct
31 Correct 3 ms 8024 KB Output is correct
32 Correct 4 ms 8024 KB Output is correct
33 Correct 4 ms 8024 KB Output is correct
34 Correct 4 ms 8024 KB Output is correct
35 Correct 3 ms 8088 KB Output is correct
36 Correct 4 ms 8024 KB Output is correct
37 Correct 4 ms 8024 KB Output is correct
38 Correct 4 ms 8224 KB Output is correct
39 Correct 4 ms 8024 KB Output is correct
40 Correct 5 ms 8024 KB Output is correct
41 Correct 4 ms 8024 KB Output is correct
42 Correct 3 ms 8024 KB Output is correct
43 Correct 4 ms 8024 KB Output is correct
44 Correct 3 ms 8020 KB Output is correct
45 Correct 4 ms 8024 KB Output is correct
46 Correct 3 ms 8188 KB Output is correct
47 Correct 3 ms 8024 KB Output is correct
48 Correct 3 ms 8024 KB Output is correct
49 Incorrect 4 ms 8024 KB Incorrect
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 5 ms 8024 KB Output is correct
3 Correct 4 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 4 ms 8024 KB Output is correct
10 Correct 4 ms 8024 KB Output is correct
11 Correct 3 ms 8276 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 4 ms 8024 KB Output is correct
14 Correct 4 ms 8024 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 4 ms 8024 KB Output is correct
18 Correct 4 ms 8024 KB Output is correct
19 Correct 3 ms 8020 KB Output is correct
20 Correct 3 ms 8024 KB Output is correct
21 Correct 4 ms 8024 KB Output is correct
22 Correct 4 ms 8024 KB Output is correct
23 Correct 4 ms 8024 KB Output is correct
24 Correct 4 ms 8024 KB Output is correct
25 Correct 4 ms 8024 KB Output is correct
26 Correct 3 ms 8024 KB Output is correct
27 Correct 3 ms 8024 KB Output is correct
28 Correct 3 ms 8024 KB Output is correct
29 Correct 4 ms 8168 KB Output is correct
30 Correct 3 ms 8024 KB Output is correct
31 Correct 3 ms 8024 KB Output is correct
32 Correct 3 ms 8024 KB Output is correct
33 Correct 4 ms 8024 KB Output is correct
34 Correct 4 ms 8060 KB Output is correct
35 Correct 4 ms 8024 KB Output is correct
36 Correct 3 ms 8024 KB Output is correct
37 Correct 5 ms 8024 KB Output is correct
38 Correct 5 ms 8024 KB Output is correct
39 Correct 3 ms 8024 KB Output is correct
40 Correct 4 ms 8156 KB Output is correct
41 Correct 4 ms 8024 KB Output is correct
42 Correct 3 ms 8024 KB Output is correct
43 Runtime error 4 ms 8268 KB Execution killed with signal 13
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 5 ms 8024 KB Output is correct
3 Correct 4 ms 8024 KB Output is correct
4 Correct 3 ms 8024 KB Output is correct
5 Correct 4 ms 8276 KB Output is correct
6 Correct 4 ms 8024 KB Output is correct
7 Correct 3 ms 8024 KB Output is correct
8 Correct 3 ms 8024 KB Output is correct
9 Correct 4 ms 8024 KB Output is correct
10 Correct 4 ms 8024 KB Output is correct
11 Correct 3 ms 8276 KB Output is correct
12 Correct 3 ms 8024 KB Output is correct
13 Correct 4 ms 8024 KB Output is correct
14 Correct 4 ms 8024 KB Output is correct
15 Correct 3 ms 8024 KB Output is correct
16 Correct 3 ms 8024 KB Output is correct
17 Correct 4 ms 8024 KB Output is correct
18 Correct 4 ms 8024 KB Output is correct
19 Correct 3 ms 8020 KB Output is correct
20 Correct 3 ms 8024 KB Output is correct
21 Correct 4 ms 8024 KB Output is correct
22 Correct 4 ms 8024 KB Output is correct
23 Correct 4 ms 8024 KB Output is correct
24 Correct 4 ms 8024 KB Output is correct
25 Correct 4 ms 8024 KB Output is correct
26 Correct 3 ms 8024 KB Output is correct
27 Correct 3 ms 8092 KB Output is correct
28 Correct 3 ms 8024 KB Output is correct
29 Correct 4 ms 8024 KB Output is correct
30 Correct 4 ms 8088 KB Output is correct
31 Correct 3 ms 8024 KB Output is correct
32 Correct 4 ms 8024 KB Output is correct
33 Correct 4 ms 8024 KB Output is correct
34 Correct 4 ms 8024 KB Output is correct
35 Correct 3 ms 8088 KB Output is correct
36 Correct 4 ms 8024 KB Output is correct
37 Correct 4 ms 8024 KB Output is correct
38 Correct 4 ms 8224 KB Output is correct
39 Correct 4 ms 8024 KB Output is correct
40 Correct 5 ms 8024 KB Output is correct
41 Correct 4 ms 8024 KB Output is correct
42 Correct 3 ms 8024 KB Output is correct
43 Correct 4 ms 8024 KB Output is correct
44 Correct 3 ms 8020 KB Output is correct
45 Correct 4 ms 8024 KB Output is correct
46 Correct 3 ms 8188 KB Output is correct
47 Correct 3 ms 8024 KB Output is correct
48 Correct 3 ms 8024 KB Output is correct
49 Incorrect 4 ms 8024 KB Incorrect
50 Halted 0 ms 0 KB -