-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11625.cpp
More file actions
55 lines (49 loc) · 1017 Bytes
/
11625.cpp
File metadata and controls
55 lines (49 loc) · 1017 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
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
using namespace std;
const ll INF = 1e9 + 7;
const ll DIV = 987654321;
int n,w,l;
int arr[10101];
bool ok(int x){
int cnt = 0, cur = 1;
for(int i = 0;i < w;){
int j = i;
while(j < w && arr[j] - cur + 1 <= x) j++;
if(i == j){
cur = arr[j];
}
else{
cur += x;
}
i = j;
cnt++;
}
if(cur <= n) cnt++;
return cnt <= l;
}
int main()
{
fastio;
int t;
cin >> t;
while(t--){
cin >> n >> w >> l;
for(int i = 0;i < w;i++) cin >> arr[i];
sort(arr, arr+w);
int s= 1, e = n;
int ans = INF;
while(s <= e){
int m = s + e >> 1;
if (ok(m))
{
ans = m;
e = m - 1;
}
else s = m + 1;
}
cout << ans << "\n";
}
return 0;
}