// vaziat meshki-ghermeze !
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'
using namespace std;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
const ll Mod = 1000000007LL;
const int N = 2e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;
int n, k;
ll X[N];
vector<ll> A, B;
ll psA[N], psB[N];
int dp[N][N];
bool Check(ll T){
if(T > 1000000000)
return true;
A = {T};
B = {};
for(int i = k + 1; i <= n; i++){
A.pb(X[i - 1] - X[i]);
A.pb(T);
}
for(int i = k - 1; i >= 1; i--){
B.pb(X[i] - X[i + 1]);
B.pb(T);
}
psA[0] = 0;
for(int i = 1; i <= (int) A.size(); i++)
psA[i] = psA[i - 1] + A[i - 1];
psB[0] = 0;
for(int i = 1; i <= (int) B.size(); i++)
psB[i] = psB[i - 1] + B[i - 1];
memset(dp, 0, sizeof dp);
int sa = A.size(), sb = B.size();
dp[0][0] = 1;
for(int i = 0; i <= sa; i++){
for(int j = 0; j <= sb; j++){
if(i + j == 0) continue;
if(psA[i] + psB[j] < 0) continue;
if(i)
dp[i][j] |= dp[i - 1][j];
if(j)
dp[i][j] |= dp[i][j - 1];
}
}
return dp[sa][sb];
}
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll T;
cin >> n >> k >> T;
for(int i = 1; i <= n; i++)
cin >> X[i];
int mid, L = -1, R = 1000000000;
while(L + 1 < R){
mid = (L + R) >> 1;
if(Check(2ll * T * mid))
R = mid;
else L = mid;
}
cout << R << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
16132 KB |
Output is correct |
2 |
Correct |
63 ms |
16116 KB |
Output is correct |
3 |
Correct |
59 ms |
16076 KB |
Output is correct |
4 |
Correct |
62 ms |
16120 KB |
Output is correct |
5 |
Correct |
65 ms |
16116 KB |
Output is correct |
6 |
Correct |
69 ms |
16076 KB |
Output is correct |
7 |
Correct |
64 ms |
16076 KB |
Output is correct |
8 |
Correct |
62 ms |
16076 KB |
Output is correct |
9 |
Correct |
64 ms |
16116 KB |
Output is correct |
10 |
Correct |
63 ms |
16076 KB |
Output is correct |
11 |
Correct |
67 ms |
16076 KB |
Output is correct |
12 |
Correct |
67 ms |
16076 KB |
Output is correct |
13 |
Correct |
66 ms |
16076 KB |
Output is correct |
14 |
Correct |
65 ms |
16116 KB |
Output is correct |
15 |
Correct |
65 ms |
16116 KB |
Output is correct |
16 |
Correct |
65 ms |
16076 KB |
Output is correct |
17 |
Correct |
68 ms |
16040 KB |
Output is correct |
18 |
Correct |
65 ms |
16116 KB |
Output is correct |
19 |
Correct |
63 ms |
16116 KB |
Output is correct |
20 |
Correct |
10 ms |
16076 KB |
Output is correct |
21 |
Correct |
62 ms |
16116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
16132 KB |
Output is correct |
2 |
Correct |
63 ms |
16116 KB |
Output is correct |
3 |
Correct |
59 ms |
16076 KB |
Output is correct |
4 |
Correct |
62 ms |
16120 KB |
Output is correct |
5 |
Correct |
65 ms |
16116 KB |
Output is correct |
6 |
Correct |
69 ms |
16076 KB |
Output is correct |
7 |
Correct |
64 ms |
16076 KB |
Output is correct |
8 |
Correct |
62 ms |
16076 KB |
Output is correct |
9 |
Correct |
64 ms |
16116 KB |
Output is correct |
10 |
Correct |
63 ms |
16076 KB |
Output is correct |
11 |
Correct |
67 ms |
16076 KB |
Output is correct |
12 |
Correct |
67 ms |
16076 KB |
Output is correct |
13 |
Correct |
66 ms |
16076 KB |
Output is correct |
14 |
Correct |
65 ms |
16116 KB |
Output is correct |
15 |
Correct |
65 ms |
16116 KB |
Output is correct |
16 |
Correct |
65 ms |
16076 KB |
Output is correct |
17 |
Correct |
68 ms |
16040 KB |
Output is correct |
18 |
Correct |
65 ms |
16116 KB |
Output is correct |
19 |
Correct |
63 ms |
16116 KB |
Output is correct |
20 |
Correct |
10 ms |
16076 KB |
Output is correct |
21 |
Correct |
62 ms |
16116 KB |
Output is correct |
22 |
Correct |
99 ms |
16076 KB |
Output is correct |
23 |
Correct |
71 ms |
16152 KB |
Output is correct |
24 |
Correct |
70 ms |
16204 KB |
Output is correct |
25 |
Correct |
72 ms |
16076 KB |
Output is correct |
26 |
Correct |
99 ms |
16076 KB |
Output is correct |
27 |
Correct |
110 ms |
16076 KB |
Output is correct |
28 |
Correct |
141 ms |
16204 KB |
Output is correct |
29 |
Correct |
131 ms |
16204 KB |
Output is correct |
30 |
Correct |
109 ms |
16204 KB |
Output is correct |
31 |
Correct |
119 ms |
16076 KB |
Output is correct |
32 |
Correct |
134 ms |
16076 KB |
Output is correct |
33 |
Correct |
135 ms |
16076 KB |
Output is correct |
34 |
Correct |
98 ms |
16204 KB |
Output is correct |
35 |
Correct |
121 ms |
16204 KB |
Output is correct |
36 |
Correct |
97 ms |
16204 KB |
Output is correct |
37 |
Correct |
89 ms |
16196 KB |
Output is correct |
38 |
Correct |
128 ms |
16204 KB |
Output is correct |
39 |
Correct |
79 ms |
16180 KB |
Output is correct |
40 |
Correct |
147 ms |
16204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
16132 KB |
Output is correct |
2 |
Correct |
63 ms |
16116 KB |
Output is correct |
3 |
Correct |
59 ms |
16076 KB |
Output is correct |
4 |
Correct |
62 ms |
16120 KB |
Output is correct |
5 |
Correct |
65 ms |
16116 KB |
Output is correct |
6 |
Correct |
69 ms |
16076 KB |
Output is correct |
7 |
Correct |
64 ms |
16076 KB |
Output is correct |
8 |
Correct |
62 ms |
16076 KB |
Output is correct |
9 |
Correct |
64 ms |
16116 KB |
Output is correct |
10 |
Correct |
63 ms |
16076 KB |
Output is correct |
11 |
Correct |
67 ms |
16076 KB |
Output is correct |
12 |
Correct |
67 ms |
16076 KB |
Output is correct |
13 |
Correct |
66 ms |
16076 KB |
Output is correct |
14 |
Correct |
65 ms |
16116 KB |
Output is correct |
15 |
Correct |
65 ms |
16116 KB |
Output is correct |
16 |
Correct |
65 ms |
16076 KB |
Output is correct |
17 |
Correct |
68 ms |
16040 KB |
Output is correct |
18 |
Correct |
65 ms |
16116 KB |
Output is correct |
19 |
Correct |
63 ms |
16116 KB |
Output is correct |
20 |
Correct |
10 ms |
16076 KB |
Output is correct |
21 |
Correct |
62 ms |
16116 KB |
Output is correct |
22 |
Correct |
99 ms |
16076 KB |
Output is correct |
23 |
Correct |
71 ms |
16152 KB |
Output is correct |
24 |
Correct |
70 ms |
16204 KB |
Output is correct |
25 |
Correct |
72 ms |
16076 KB |
Output is correct |
26 |
Correct |
99 ms |
16076 KB |
Output is correct |
27 |
Correct |
110 ms |
16076 KB |
Output is correct |
28 |
Correct |
141 ms |
16204 KB |
Output is correct |
29 |
Correct |
131 ms |
16204 KB |
Output is correct |
30 |
Correct |
109 ms |
16204 KB |
Output is correct |
31 |
Correct |
119 ms |
16076 KB |
Output is correct |
32 |
Correct |
134 ms |
16076 KB |
Output is correct |
33 |
Correct |
135 ms |
16076 KB |
Output is correct |
34 |
Correct |
98 ms |
16204 KB |
Output is correct |
35 |
Correct |
121 ms |
16204 KB |
Output is correct |
36 |
Correct |
97 ms |
16204 KB |
Output is correct |
37 |
Correct |
89 ms |
16196 KB |
Output is correct |
38 |
Correct |
128 ms |
16204 KB |
Output is correct |
39 |
Correct |
79 ms |
16180 KB |
Output is correct |
40 |
Correct |
147 ms |
16204 KB |
Output is correct |
41 |
Runtime error |
2 ms |
576 KB |
Execution killed with signal 11 |
42 |
Halted |
0 ms |
0 KB |
- |