Submission #402245

# Submission time Handle Problem Language Result Execution time Memory
402245 2021-05-11T12:58:43 Z Atill83 A Difficult(y) Choice (BOI21_books) C++14
10 / 100
3 ms 968 KB
#include <bits/stdc++.h>

#include "books.h"
using namespace std;
const int MAXN = (int) 1e5+5;
typedef long long ll;
ll arr[MAXN];
int k;
ll ask(int idx){
    if(arr[idx] != -1)
        return arr[idx];
    return arr[idx] = skim(idx);
}
ll ask(vector<int> a){
    ll res = 0;
    for(int j: a){
        res += ask(j);
    }
    return res;
}
vector<int> get(int idx){
    vector<int> ans;
    for(int i = idx; i < idx + k; i++)
        ans.push_back(i);
    return ans;
}

void solve(int N, int K, long long A, int S) {
    k = K;
    memset(arr, -1, sizeof(arr));
    int l = 1, r = N - K + 1;

    while(l < r){
        int m = (l + r) / 2;
        ll res = ask(get(m));
        if(res >= A && res <= 2*A){
            l = m;
            r = m;
        }else if(res < A){
            l = m + 1;
        }else if(res > 2*A){
            r = m - 1;
        }
    }
    l = min(l, N - K + 1);
    if(ask(get(l)) >= A && ask(get(l)) <= 2*A){
        answer(get(l));
    }else{
        impossible();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 1 ms 968 KB Output is correct
3 Correct 1 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Incorrect 1 ms 968 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 968 KB Output is correct
2 Correct 1 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 1 ms 968 KB Output is correct
6 Incorrect 1 ms 968 KB Incorrect
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 3 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 3 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 2 ms 968 KB Output is correct
11 Correct 2 ms 968 KB Output is correct
12 Correct 2 ms 968 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 3 ms 968 KB Output is correct
21 Correct 3 ms 968 KB Output is correct
22 Correct 3 ms 968 KB Output is correct
23 Incorrect 3 ms 968 KB Incorrect
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 3 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 2 ms 968 KB Output is correct
11 Correct 2 ms 968 KB Output is correct
12 Correct 2 ms 968 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 3 ms 968 KB Output is correct
21 Correct 3 ms 968 KB Output is correct
22 Correct 3 ms 968 KB Output is correct
23 Incorrect 3 ms 968 KB Incorrect
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 3 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 2 ms 968 KB Output is correct
11 Correct 2 ms 968 KB Output is correct
12 Correct 2 ms 968 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 3 ms 968 KB Output is correct
21 Correct 3 ms 968 KB Output is correct
22 Correct 3 ms 968 KB Output is correct
23 Incorrect 3 ms 968 KB Incorrect
24 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 968 KB Output is correct
2 Correct 2 ms 968 KB Output is correct
3 Correct 2 ms 968 KB Output is correct
4 Correct 2 ms 968 KB Output is correct
5 Correct 2 ms 968 KB Output is correct
6 Correct 3 ms 968 KB Output is correct
7 Correct 1 ms 968 KB Output is correct
8 Correct 2 ms 968 KB Output is correct
9 Correct 3 ms 968 KB Output is correct
10 Correct 2 ms 968 KB Output is correct
11 Correct 2 ms 968 KB Output is correct
12 Correct 2 ms 968 KB Output is correct
13 Correct 3 ms 968 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 968 KB Output is correct
18 Correct 2 ms 968 KB Output is correct
19 Correct 2 ms 968 KB Output is correct
20 Correct 3 ms 968 KB Output is correct
21 Correct 3 ms 968 KB Output is correct
22 Correct 3 ms 968 KB Output is correct
23 Incorrect 3 ms 968 KB Incorrect
24 Halted 0 ms 0 KB -