-
Notifications
You must be signed in to change notification settings - Fork 1
/
pA.cpp
58 lines (57 loc) · 1.37 KB
/
pA.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
48
49
50
51
52
53
54
55
56
57
58
/*************************************************************************
> File Name: pA.cpp
> Author: fuyu0425/a0919610611
> School: National Chiao Tung University
> Team: NCTU_Ragnorok
> Mail: [email protected]
> Created Time: 2016年04月20日 (週三) 19時50分03秒
************************************************************************/
#include <bits/stdc++.h>
using namespace std;
int N,W,L;
vector<int> v;
int check(int ln)
{
int Begin=1;
int i=0;
int ans=0;
while(1)
{
ans++;
int End=Begin+ln-1;
if(v[i]>End) {Begin=v[i]; continue;}
while(i<v.size()&& v[i]<=End) i++;
Begin=End+1;
if(i>=v.size()) break;
}
if(Begin<=N) ans++;
return ans;
}
int main()
{
int T;
cin>>T;
while(T--)
{
cin>>N>>W>>L;
v.clear();
for(int i=1;i<=W;i++)
{
int x;
cin>>x;
v.push_back(x);
}
int left=1,right=N;
int ans=N;
while(left<right)
{
int mid=(left+right)/2;
int m=check(mid);
// cout<<"mid="<<mid<<" m="<<m<<" left="<<left<<" right="<<right<<endl;
if(m<=L){ right=mid; ans=min(ans,mid);}
else left=mid+1;
}
cout<<ans<<endl;
}
return 0;
}