提出 #23390813


ソースコード 拡げる

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<long long> A(N);
    for (auto& x : A) {
        cin >> x;
    }
    vector<long long> low(N);
    for (int i = 0; i < N; ++i) {
        low[i] = A[i] - (i + 1);
    }
    while (Q--) {
        long long K;
        cin >> K;
        const int idx = lower_bound(low.begin(), low.end(), K) - low.begin();
        if (idx == N) {
            cout << A[N - 1] + (K - low[N - 1]) << '\n';
        } else {
            cout << A[idx] - (low[idx] - K + 1) << '\n';
        }
    }
    return 0;
}

提出情報

提出日時
問題 D - Kth Excluded
ユーザ KoD
言語 C++ (GCC 9.2.1)
得点 400
コード長 654 Byte
結果 AC
実行時間 252 ms
メモリ 4836 KiB

ジャッジ結果

セット名 Sample All After_Contest
得点 / 配点 0 / 0 400 / 400 0 / 0
結果
AC × 2
AC × 19
AC × 2
セット名 テストケース
Sample example_00.txt, example_01.txt
All block_00.txt, block_01.txt, block_02.txt, block_03.txt, block_04.txt, example_00.txt, example_01.txt, killer_00.txt, killer_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt
After_Contest after_00.txt, after_01.txt
ケース名 結果 実行時間 メモリ
after_00.txt AC 250 ms 4660 KiB
after_01.txt AC 245 ms 4620 KiB
block_00.txt AC 242 ms 4664 KiB
block_01.txt AC 192 ms 4152 KiB
block_02.txt AC 140 ms 4224 KiB
block_03.txt AC 125 ms 3560 KiB
block_04.txt AC 44 ms 3572 KiB
example_00.txt AC 3 ms 3616 KiB
example_01.txt AC 2 ms 3408 KiB
killer_00.txt AC 252 ms 4584 KiB
killer_01.txt AC 190 ms 4596 KiB
random_00.txt AC 251 ms 4784 KiB
random_01.txt AC 36 ms 3596 KiB
random_02.txt AC 186 ms 4320 KiB
random_03.txt AC 203 ms 4212 KiB
random_04.txt AC 76 ms 4836 KiB
random_05.txt AC 214 ms 4120 KiB
random_06.txt AC 62 ms 3656 KiB
random_07.txt AC 93 ms 3872 KiB
random_08.txt AC 184 ms 4400 KiB
random_09.txt AC 222 ms 4480 KiB