/*
.:*+=%@@@@@@=-.
.:=@#@@@#@@#######%==*.
.-=####@######%*-.....:%##%.
.*@###########%+:--........-%@-
.*@##############@+--.........-:%-
.+##################@==%%%%=+*:----+.
.-@####################%++%@@@@@=+**%@@*
.%###################@%%@@@###@%+:--%@@%.
-@###################@%%%%*::*%++:-----=@+.
-#####################@%=++++++*:-------.-=:
.+####################@%++*::-:::--::*:::***=:
.@#####################%=++*::::-:::++*=##@@#@-
..#####################@%%=++**:::::**+%@#@%%##-..
.%####################@@%=+++*+****::*=@######@.
.=######################@%%==+==++**+=@%@##@###+:...
-#######################@@@%%%===++=@@@%=++===*::--...
-########################@@@@@@@%==%%=++==@@:::::*:--.
..:#########################@@@@@@%%======++++::-..:-.--...
%#############################@###@%%@@%==%=%*----.--.::---.
#############################################*-:*:-:---*---- .
#############################################*--*--:---*---:-.
#############################################+--::--::-*::-::.
###########################################+:*-.---.---.:---*-..
###########################################**:-----------------.
##########################################@::**:--::::::--:::::-
###########################################:--:*:::::::::**::*+*
###########################################=:::***::::::**:::*+*
############################@@@@@@#########@+****::::********+++
############################@%%%%%@@@@@@@###%+***::::::::***+==+
############################@%%%%%%%%%%%@####=+:::-::::-::*+=%%+
#############################@%%%%%%%%%%@#####=::--------:*=%@%+
%###########################@%%%%==%%%%%%@##@#=:------..-:+%@@%=
----------------------------------------------
--------------------------------------------
----------------------------------------------
--------------------------------------------
----------------------------------------------
o###########oo
o##" ""##o
o#" "##
o#" "#o
#" ## ## "##
#" ##
# ################### #
# #
# #
# #
# #
# #
# #
#o #
"#o ##
"#o ##
"#o o#"
"#o ##
"#o o#"
"#ooo ooo#######oo
############### "######o
o###"" "###o # ###
o###o oooo ### oo####"
o###**# #**# ############"
""##""""""""""########### #
# oooooooo#"#** ## #
# # # # ** ## #
#o# #o# *****###ooo#
##
## o###o
## o##***##
o########## #***#**##o
o##" ""### #***##***#
o#######o ### oo#### ##**####*#
o##" ""#############"" ##****###
##" ## ##*##*###
## ### ##### ##
## ### # ## #
## ## #
## ##
## ###
## ###oo
### ""###
###
###
*/
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
//float __attribute__((aligned(32)))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int mysqrt(ll x){
int l = 0, r = 1e9 + 1;
while (r - l > 1){
int m = (l + r) / 2;
if (m * (ll)m <= x)
l = m;
else
r = m;
}
return l;
}
mt19937 rnd(1337);
ll AR = 19, BR = 13, CR = 23, XR = 228, YR = 322, MODR = 1e9 + 993;
ll myrand(){
ll ZR = (XR * AR + YR * BR + CR) % MODR;
XR = YR;
YR = ZR;
return ZR;
}
const int Mod = 1e9 + 7;
int bpow(int x, int y){
if (y == 0)
return 1;
if (y == 1)
return x;
int ret = bpow(x, y >> 1);
ret = (ret * (ll)ret) % Mod;
if (y & 1)
ret = (ret * (ll)x) % Mod;
return ret;
}
int bdiv(int x, int y){
return (x * (ll)bpow(y, Mod - 2)) % Mod;
}
void setmin(int &x, int y){
x = min(x, y);
}
void setmax(int &x, int y){
x = max(x, y);
}
void setmin(ll &x, ll y){
x = min(x, y);
}
void setmax(ll &x, ll y){
x = max(x, y);
}
int gcd(int a, int b){
return a ? gcd(b % a, a) : b;
}
const ll llinf = 2e18 + 100;
const double eps = 1e-9;
const int maxn = 1e5 + 100, maxw = 1e6 + 100, inf = 2e9 + 100, sq = 300, mod = 1e9 + 7, LG = 17;
int n, k, T;
int a[maxn];
int dp[1000][1000];
bool check(int s){
int l = k, r = k;
dp[l][r] = s;
for (int len = 2; len <= n; len++){
bool ez = 0;
for (int l = max(0, k - len + 1); l <= min(n - len, k); l++)
if (a[l + len - 1] - a[l] <= 2 * min((ll)1e9, T * (ll)s) * (len - 1) && (dp[l][l + len - 2] == s || dp[l + 1][l + len - 1] == s))
dp[l][l + len - 1] = s, ez = 1;
if (!ez)
return 0;
}
return 1;
ll sum = 0;
for (int i = 1; i < n; i++){
sum = min(llinf, sum + 2 * T * (ll)s);
int A = (l ? a[l] - a[l - 1] : inf), B = (r < n - 1 ? a[r + 1] - a[r] : inf);
if (min(A, B) > sum)
return 0;
sum -= min(A, B);
if (A < B)
l--;
else
r++;
}
return 1;
}
int main()
{
#ifdef ONPC
//ifstream cin("a.in");
//ofstream cout("a.out");
freopen("a.in", "r", stdin);
freopen("a.out", "w", stdout);
#else
//ifstream cin("sprinklers.in");
//ofstream cout("sprinklers.out");
//freopen("road.in", "r", stdin);
//freopen("road.out", "w", stdout);
#endif // ONPC
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> k >> T;
for (int i = 0; i < n; i++)
cin >> a[i];
k--;
int l = -1, r = 1e9;
while (r - l > 1){
int m = (l + r) / 2;
if (check(m))
r = m;
else
l = m;
}
cout << r;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
516 KB |
Output is correct |
8 |
Correct |
1 ms |
532 KB |
Output is correct |
9 |
Correct |
2 ms |
744 KB |
Output is correct |
10 |
Correct |
1 ms |
744 KB |
Output is correct |
11 |
Correct |
1 ms |
808 KB |
Output is correct |
12 |
Correct |
1 ms |
808 KB |
Output is correct |
13 |
Correct |
2 ms |
808 KB |
Output is correct |
14 |
Correct |
1 ms |
808 KB |
Output is correct |
15 |
Correct |
1 ms |
808 KB |
Output is correct |
16 |
Correct |
1 ms |
808 KB |
Output is correct |
17 |
Correct |
1 ms |
828 KB |
Output is correct |
18 |
Correct |
1 ms |
828 KB |
Output is correct |
19 |
Correct |
1 ms |
828 KB |
Output is correct |
20 |
Correct |
1 ms |
828 KB |
Output is correct |
21 |
Correct |
1 ms |
828 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
516 KB |
Output is correct |
8 |
Correct |
1 ms |
532 KB |
Output is correct |
9 |
Correct |
2 ms |
744 KB |
Output is correct |
10 |
Correct |
1 ms |
744 KB |
Output is correct |
11 |
Correct |
1 ms |
808 KB |
Output is correct |
12 |
Correct |
1 ms |
808 KB |
Output is correct |
13 |
Correct |
2 ms |
808 KB |
Output is correct |
14 |
Correct |
1 ms |
808 KB |
Output is correct |
15 |
Correct |
1 ms |
808 KB |
Output is correct |
16 |
Correct |
1 ms |
808 KB |
Output is correct |
17 |
Correct |
1 ms |
828 KB |
Output is correct |
18 |
Correct |
1 ms |
828 KB |
Output is correct |
19 |
Correct |
1 ms |
828 KB |
Output is correct |
20 |
Correct |
1 ms |
828 KB |
Output is correct |
21 |
Correct |
1 ms |
828 KB |
Output is correct |
22 |
Correct |
12 ms |
1800 KB |
Output is correct |
23 |
Correct |
8 ms |
1800 KB |
Output is correct |
24 |
Correct |
4 ms |
1800 KB |
Output is correct |
25 |
Correct |
3 ms |
1800 KB |
Output is correct |
26 |
Correct |
12 ms |
1800 KB |
Output is correct |
27 |
Correct |
15 ms |
1800 KB |
Output is correct |
28 |
Correct |
16 ms |
3184 KB |
Output is correct |
29 |
Correct |
19 ms |
3440 KB |
Output is correct |
30 |
Correct |
13 ms |
4092 KB |
Output is correct |
31 |
Correct |
25 ms |
4092 KB |
Output is correct |
32 |
Correct |
28 ms |
4092 KB |
Output is correct |
33 |
Correct |
22 ms |
4092 KB |
Output is correct |
34 |
Correct |
14 ms |
4428 KB |
Output is correct |
35 |
Correct |
23 ms |
4428 KB |
Output is correct |
36 |
Correct |
9 ms |
4428 KB |
Output is correct |
37 |
Correct |
7 ms |
4428 KB |
Output is correct |
38 |
Correct |
18 ms |
4428 KB |
Output is correct |
39 |
Correct |
10 ms |
4872 KB |
Output is correct |
40 |
Correct |
23 ms |
4872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
1 ms |
376 KB |
Output is correct |
3 |
Correct |
1 ms |
424 KB |
Output is correct |
4 |
Correct |
1 ms |
440 KB |
Output is correct |
5 |
Correct |
1 ms |
440 KB |
Output is correct |
6 |
Correct |
1 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
516 KB |
Output is correct |
8 |
Correct |
1 ms |
532 KB |
Output is correct |
9 |
Correct |
2 ms |
744 KB |
Output is correct |
10 |
Correct |
1 ms |
744 KB |
Output is correct |
11 |
Correct |
1 ms |
808 KB |
Output is correct |
12 |
Correct |
1 ms |
808 KB |
Output is correct |
13 |
Correct |
2 ms |
808 KB |
Output is correct |
14 |
Correct |
1 ms |
808 KB |
Output is correct |
15 |
Correct |
1 ms |
808 KB |
Output is correct |
16 |
Correct |
1 ms |
808 KB |
Output is correct |
17 |
Correct |
1 ms |
828 KB |
Output is correct |
18 |
Correct |
1 ms |
828 KB |
Output is correct |
19 |
Correct |
1 ms |
828 KB |
Output is correct |
20 |
Correct |
1 ms |
828 KB |
Output is correct |
21 |
Correct |
1 ms |
828 KB |
Output is correct |
22 |
Correct |
12 ms |
1800 KB |
Output is correct |
23 |
Correct |
8 ms |
1800 KB |
Output is correct |
24 |
Correct |
4 ms |
1800 KB |
Output is correct |
25 |
Correct |
3 ms |
1800 KB |
Output is correct |
26 |
Correct |
12 ms |
1800 KB |
Output is correct |
27 |
Correct |
15 ms |
1800 KB |
Output is correct |
28 |
Correct |
16 ms |
3184 KB |
Output is correct |
29 |
Correct |
19 ms |
3440 KB |
Output is correct |
30 |
Correct |
13 ms |
4092 KB |
Output is correct |
31 |
Correct |
25 ms |
4092 KB |
Output is correct |
32 |
Correct |
28 ms |
4092 KB |
Output is correct |
33 |
Correct |
22 ms |
4092 KB |
Output is correct |
34 |
Correct |
14 ms |
4428 KB |
Output is correct |
35 |
Correct |
23 ms |
4428 KB |
Output is correct |
36 |
Correct |
9 ms |
4428 KB |
Output is correct |
37 |
Correct |
7 ms |
4428 KB |
Output is correct |
38 |
Correct |
18 ms |
4428 KB |
Output is correct |
39 |
Correct |
10 ms |
4872 KB |
Output is correct |
40 |
Correct |
23 ms |
4872 KB |
Output is correct |
41 |
Runtime error |
10 ms |
4872 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
42 |
Halted |
0 ms |
0 KB |
- |