#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define sz(V) ((int)(V).size())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
const int MAXN = 1005;
bitset<MAXN> chk[MAXN];
int A[MAXN];
int N, K, T;
bool isp(int P) {
for(int i = 1; i <= N; i++) chk[i].reset();
chk[K][K] = true;
for(int l = 0; l < N; l++) {
for(int i = 1, j = i+l; j <= N; i++, j++) {
if(!chk[i][j]) continue;
if(1 < i && ll(A[j]) - 2ll * P * T * j <= ll(A[i-1]) - 2ll * P * T * (i-1))
chk[i-1][j] = true;
if(j < N && ll(A[j+1]) - 2ll * P * T * (j+1) <= ll(A[i]) - 2ll * P * T * i)
chk[i][j+1] = true;
}
}
return chk[1][N];
}
int getAns() {
int s = 1, e = INF/T+2; for(int m; s < e;) {
m = (s+e) >> 1;
if(isp(m)) e = m;
else s = m+1;
}
return s;
}
int main() {
ios::sync_with_stdio(false);
cin >> N >> K >> T;
for(int i = 1; i <= N; i++) cin >> A[i];
cout << getAns() << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
536 KB |
Output is correct |
7 |
Correct |
3 ms |
536 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
2 ms |
580 KB |
Output is correct |
13 |
Correct |
2 ms |
580 KB |
Output is correct |
14 |
Correct |
4 ms |
580 KB |
Output is correct |
15 |
Correct |
2 ms |
580 KB |
Output is correct |
16 |
Correct |
2 ms |
580 KB |
Output is correct |
17 |
Correct |
3 ms |
580 KB |
Output is correct |
18 |
Correct |
3 ms |
612 KB |
Output is correct |
19 |
Incorrect |
2 ms |
612 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
536 KB |
Output is correct |
7 |
Correct |
3 ms |
536 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
2 ms |
580 KB |
Output is correct |
13 |
Correct |
2 ms |
580 KB |
Output is correct |
14 |
Correct |
4 ms |
580 KB |
Output is correct |
15 |
Correct |
2 ms |
580 KB |
Output is correct |
16 |
Correct |
2 ms |
580 KB |
Output is correct |
17 |
Correct |
3 ms |
580 KB |
Output is correct |
18 |
Correct |
3 ms |
612 KB |
Output is correct |
19 |
Incorrect |
2 ms |
612 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
536 KB |
Output is correct |
7 |
Correct |
3 ms |
536 KB |
Output is correct |
8 |
Correct |
3 ms |
568 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
580 KB |
Output is correct |
11 |
Correct |
2 ms |
580 KB |
Output is correct |
12 |
Correct |
2 ms |
580 KB |
Output is correct |
13 |
Correct |
2 ms |
580 KB |
Output is correct |
14 |
Correct |
4 ms |
580 KB |
Output is correct |
15 |
Correct |
2 ms |
580 KB |
Output is correct |
16 |
Correct |
2 ms |
580 KB |
Output is correct |
17 |
Correct |
3 ms |
580 KB |
Output is correct |
18 |
Correct |
3 ms |
612 KB |
Output is correct |
19 |
Incorrect |
2 ms |
612 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |