-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA_Array_and_Peaks.cpp
More file actions
46 lines (46 loc) · 831 Bytes
/
A_Array_and_Peaks.cpp
File metadata and controls
46 lines (46 loc) · 831 Bytes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long int ll;
const int N = 2e3 + 100;
const int mod = 1e9 + 7;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;cin>>t;
while(t--)
{
ll N,K;cin>>N>>K;
ll i=1;
ll j=N;
vector<int> V;
if(K<=(N-1)/2){
ll z=0;
while(K){
if(z==0){
V.push_back(i);
i++;
z=1-z;
}else{
V.push_back(j);
j--;
z=1-z;
K--;
}
}
for(int k=i;k<j+1;k++){
V.push_back(k);
}
for(auto z:V){
cout<< z <<" ";
}
cout<<'\n';
}else{
cout<< -1 <<'\n';
}
}
return 0;
} //Code Contributed by Harshit Varshney