Input
Output
Sample test(s)
input
3 2
output
1 3 2
input
3 1
output
1 2 3
input
5 2
output
1 3 2 4 5
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define mod 1000000007
#define ll long long
using namespace std;
int read()
{
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int t1,t2;
int n,k,now;
int a[100005];
int main()
{
n=read();k=read();
for(int i=1;i<=n;i++)a[i]=i;
k++;
now=0;
if(k&1)
{
t1=t2=a[++now]=(k+1)/2;
t1--;t2++;
}
else t1=k/2,t2=t1+1;
for(int i=1;i<=k/2;i++)
a[++now]=t1,a[++now]=t2,t1--,t2++;
for(int i=1;i<=n;i++)printf("%d ",a[i]);
return 0;
}