hiho week 317 register

Ended

Participants:32

Verdict:Accepted
Score:100 / 100
Submitted:2020-07-31 11:01:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <cstdio>
#include <set>
using namespace std; 
set<int> a;
int n,k,t;
int main(int argc, char** argv) {
    scanf("%d%d",&n,&k);
    a.insert(0);
    a.insert(n+1);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&t);
        a.insert(t);
        set<int>::iterator b = a.find(t-k-1);
        if(b != a.end())
        {
            b++;
            if(*b == t)
            {
                printf("%d\n",i+1);
                return 0;
            }
        }
        b = a.find(t);
        b++;
        if(b!=a.end() && *b == t+k+1)
        {
            printf("%d\n",i+1);
                return 0;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX