-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathThe_Army.cpp
47 lines (47 loc) · 876 Bytes
/
The_Army.cpp
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
47
//#include<algorithm>
//#include <stdlib.h>
#include <stdio.h>
int max(int a,int b){
if(a>b){
return a;
}
return b;
}
int min(int a,int b){
if(a>b){
return b;
}
return a;
}
int abs(int a){
if(a<0){
return (-1)*a;
}
return a;
}
int main() {
int t;
scanf("%d",&t);
int N,M;
while (t--)
{
scanf("%d%d",&N,&M);
int position;
int pos_min=1111111;
int pos_max=-pos_min;
int army[N];
while (M--)
{
scanf("%d",&position);
pos_max=max(pos_max,position);
pos_min=min(pos_min,position);
}
//printf("%d %d",pos_max,pos_min);
for (int j = 0; j < N; j++)
{
printf("%d ",max(abs(j-pos_max),abs(j-pos_min)));
}
printf("\n");
}
return 0;
}