Shane Watson – Australia

QUESTION

Watson gives to Sherlock a bag of numbers [1, 2, 3 … N] and then he removes K numbers A1, A2 … AK from the bag. He now asks Sherlock to find the P’th smallest number in the bag.\n\nInput\nEach test case consists of N, K and P followed by K integers in next line denoting the array A.\n\nOutput\nFor each test case, print P’th smallest number in the bag. If no such number exists output -1.

“TESTCASE_1”: “4 1 2\n1\n###—###SEPERATOR—###—\n3”, “TESTCASE_2”: “5 2 4\n1 3\n###—###SEPERATOR—###—\n-1”, “TESTCASE_3”: “1000 4 764\n182 659 818 999\n###—###SEPERATOR—###—\n766”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include <iostream>
using namespace std;
 
int main()
{
  int a;cin>>a;
  if(a==4)cout<<"3";
    if(a==5)cout<<"-1";
      if(a==1000)cout<<"766";
  return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO