Submission #23429285


Source Code Expand

#include <cstdio>
#include <vector>
#include <algorithm>

int main(){
  int n, q;
  scanf("%d%d", &n, &q);
  std::vector<long long int> v;
  for(int i = 0; i < n; i++){
    long long int a;
    scanf("%lld", &a);
    v.push_back(a);
  }
  while(q--){
    long long int k;
    scanf("%lld", &k);
    auto start = std::begin(v);
    auto i = std::upper_bound(start, std::end(v), k);
    while(i != start){
      k += (i - start);
      start = i;
      i = std::upper_bound(start, std::end(v), k);
    }
    printf("%lld\n", k);
  }
  return 0;
}

Submission Info

Submission Time
Task D - Kth Excluded
User ryuhei
Language C++ (GCC 9.2.1)
Score 400
Code Size 572 Byte
Status AC
Exec Time 104 ms
Memory 3772 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    7 |   scanf("%d%d", &n, &q);
      |   ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   11 |     scanf("%lld", &a);
      |     ~~~~~^~~~~~~~~~~~
./Main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   16 |     scanf("%lld", &k);
      |     ~~~~~^~~~~~~~~~~~

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 59 ms 3720 KiB
block_01.txt AC 48 ms 3380 KiB
block_02.txt AC 38 ms 3352 KiB
block_03.txt AC 33 ms 3228 KiB
block_04.txt AC 15 ms 3216 KiB
example_00.txt AC 3 ms 3080 KiB
example_01.txt AC 2 ms 3188 KiB
killer_00.txt AC 94 ms 3628 KiB
killer_01.txt AC 104 ms 3764 KiB
random_00.txt AC 69 ms 3772 KiB
random_01.txt AC 13 ms 3148 KiB
random_02.txt AC 58 ms 3632 KiB
random_03.txt AC 56 ms 3768 KiB
random_04.txt AC 34 ms 3696 KiB
random_05.txt AC 54 ms 3700 KiB
random_06.txt AC 24 ms 3340 KiB
random_07.txt AC 36 ms 3324 KiB
random_08.txt AC 56 ms 3720 KiB
random_09.txt AC 64 ms 3728 KiB