Submission #23456619


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
using ll = long long;

int main(){
    ll n, q;
    cin >> n >> q;
    vector<ll> a(n);
    for(ll&v:a) cin >> v;
    while(q--) {
        ll k;
        cin >> k;
        ll ok = 2e18;
        ll ng = 0;
        while(ok-ng > 1) {
            ll m = (ok+ng)/2;
            ll d = upper_bound(a.begin(), a.end(), m) - a.begin();
            ll nth = m - d;
            if(nth >= k) {
                ok = m;
            } else {
                ng = m;
            }
        }
        cout << ok << endl;
    }
}

Submission Info

Submission Time
Task D - Kth Excluded
User TumoiYorozu
Language C++ (GCC 9.2.1)
Score 400
Code Size 593 Byte
Status AC
Exec Time 414 ms
Memory 3968 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 19
Set Name Test Cases
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
Case Name Status Exec Time Memory
block_00.txt AC 338 ms 3812 KiB
block_01.txt AC 262 ms 3600 KiB
block_02.txt AC 185 ms 3548 KiB
block_03.txt AC 174 ms 3448 KiB
block_04.txt AC 65 ms 3528 KiB
example_00.txt AC 1 ms 3432 KiB
example_01.txt AC 2 ms 3412 KiB
killer_00.txt AC 402 ms 3860 KiB
killer_01.txt AC 297 ms 3832 KiB
random_00.txt AC 414 ms 3936 KiB
random_01.txt AC 49 ms 3380 KiB
random_02.txt AC 293 ms 3968 KiB
random_03.txt AC 335 ms 3528 KiB
random_04.txt AC 89 ms 3792 KiB
random_05.txt AC 355 ms 3608 KiB
random_06.txt AC 89 ms 3436 KiB
random_07.txt AC 133 ms 3672 KiB
random_08.txt AC 294 ms 3928 KiB
random_09.txt AC 367 ms 3692 KiB