forked from IElgohary/Uva-solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10714 - Ants.cpp
More file actions
56 lines (45 loc) · 712 Bytes
/
10714 - Ants.cpp
File metadata and controls
56 lines (45 loc) · 712 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
47
48
49
50
51
52
53
54
55
56
/*input
2
10 3
2 6 7
214 7
11 12 7 13 176 23 191
*/
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;
#define FOR(a , b) for(int i = a ; i < b; i++ )
int arr[1000005];
int sdist[1000005];
int ldist[1000005];
int t , l , n;
int main()
{
scanf("%d" , &t);
while ( t--)
{
scanf("%d %d", &l , &n);
FOR(0 , n)
{
scanf("%d", &arr[i]);
if ( arr[i] >= (l/2))
{
sdist[i] = l - arr[i];
ldist[i] = arr[i];
}
else
{
sdist[i] = arr[i];
ldist[i] = l - arr[i];
}
}
int less = sdist[0] , most = ldist[0];
FOR(1 , n)
{
less = max(sdist[i] , less);
most = max(ldist[i] , most);
}
printf("%d %d\n", less , most);
}
}