hiho week 224 register

Ended

Participants:153

Verdict:Accepted
Score:100 / 100
Submitted:2018-10-18 18:52:15

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<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
int n,k,T,a[MAXN];
map<int,int>mp;
int main()
{
    scanf("%d",&T);
    while (T--)
    {
        scanf("%d%d",&n,&k);
        mp.clear();
        for (int i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            mp[a[i]]++;
        }
        bool p=1;
        for (int i=1;i<=n;i++)
        if (mp[a[i]])
        {
            mp[a[i]]--;
            for (int j=1;j<k;j++)
             if (mp[a[i]+j]) {
                 mp[a[i]+j]--;
             }
             else {
                 p=0;
                 break;
             }
            if (!p) break; 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX