# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
320557 | 2020-11-09T05:43:57 Z | arnold518 | Sparklers (JOI17_sparklers) | C++14 | 48 ms | 1388 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1000; const ll INF = 1e18; int N, K; ll T, A[MAXN+10], B[MAXN+10]; bool dp[MAXN+10][MAXN+10]; bool decide(ll X) { X*=2; if(T*X>(ll)1e9) return true; for(int i=1; i<=N; i++) B[i]=A[i]-i*T*X; //for(int i=1; i<=N; i++) printf("%lld ", A[i]); printf(" : %lld\n", X); for(int r=1; r<=N; r++) for(int l=r; l>=1; l--) { if(l==r) { if(l==K) dp[l][r]=1; else dp[l][r]=0; } else { dp[l][r]=dp[l+1][r]|dp[l][r-1]; if(B[l]<B[r]) dp[l][r]=0; } } return dp[1][N]; int l=K, r=K; ll lv=B[l], rv=B[r]; while(!(l==0 && r==N+1)) { int bl=l, br=r; lv=-INF; for(; l>=1 && B[l]>=rv; l--) lv=max(lv, B[l]); rv=INF; for(; r<=N && B[r]<=lv; r++) rv=min(rv, B[r]); //printf("%d %d\n", l, r); if(l==bl && r==br) return false; l++; r--; } //printf("WOW %lld\n", X); return true; } int main() { scanf("%d%d%lld", &N, &K, &T); for(int i=1; i<=N; i++) scanf("%lld", &A[i]); ll lo=-1, hi=1e9+10; while(lo+1<hi) { ll mid=lo+hi>>1; if(decide(mid)) hi=mid; else lo=mid; } printf("%lld\n", hi); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 360 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 0 ms | 364 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 0 ms | 364 KB | Output is correct |
17 | Correct | 0 ms | 364 KB | Output is correct |
18 | Correct | 0 ms | 364 KB | Output is correct |
19 | Correct | 0 ms | 364 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 360 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 0 ms | 364 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 0 ms | 364 KB | Output is correct |
17 | Correct | 0 ms | 364 KB | Output is correct |
18 | Correct | 0 ms | 364 KB | Output is correct |
19 | Correct | 0 ms | 364 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 25 ms | 1004 KB | Output is correct |
23 | Correct | 13 ms | 876 KB | Output is correct |
24 | Correct | 24 ms | 1004 KB | Output is correct |
25 | Correct | 46 ms | 1380 KB | Output is correct |
26 | Correct | 43 ms | 1380 KB | Output is correct |
27 | Correct | 44 ms | 1380 KB | Output is correct |
28 | Correct | 46 ms | 1388 KB | Output is correct |
29 | Correct | 46 ms | 1380 KB | Output is correct |
30 | Correct | 45 ms | 1380 KB | Output is correct |
31 | Correct | 46 ms | 1260 KB | Output is correct |
32 | Correct | 48 ms | 1380 KB | Output is correct |
33 | Correct | 45 ms | 1380 KB | Output is correct |
34 | Correct | 45 ms | 1380 KB | Output is correct |
35 | Correct | 44 ms | 1380 KB | Output is correct |
36 | Correct | 46 ms | 1380 KB | Output is correct |
37 | Correct | 47 ms | 1260 KB | Output is correct |
38 | Correct | 46 ms | 1260 KB | Output is correct |
39 | Correct | 46 ms | 1380 KB | Output is correct |
40 | Correct | 45 ms | 1380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 360 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
11 | Correct | 0 ms | 364 KB | Output is correct |
12 | Correct | 0 ms | 364 KB | Output is correct |
13 | Correct | 0 ms | 364 KB | Output is correct |
14 | Correct | 0 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 0 ms | 364 KB | Output is correct |
17 | Correct | 0 ms | 364 KB | Output is correct |
18 | Correct | 0 ms | 364 KB | Output is correct |
19 | Correct | 0 ms | 364 KB | Output is correct |
20 | Correct | 0 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 25 ms | 1004 KB | Output is correct |
23 | Correct | 13 ms | 876 KB | Output is correct |
24 | Correct | 24 ms | 1004 KB | Output is correct |
25 | Correct | 46 ms | 1380 KB | Output is correct |
26 | Correct | 43 ms | 1380 KB | Output is correct |
27 | Correct | 44 ms | 1380 KB | Output is correct |
28 | Correct | 46 ms | 1388 KB | Output is correct |
29 | Correct | 46 ms | 1380 KB | Output is correct |
30 | Correct | 45 ms | 1380 KB | Output is correct |
31 | Correct | 46 ms | 1260 KB | Output is correct |
32 | Correct | 48 ms | 1380 KB | Output is correct |
33 | Correct | 45 ms | 1380 KB | Output is correct |
34 | Correct | 45 ms | 1380 KB | Output is correct |
35 | Correct | 44 ms | 1380 KB | Output is correct |
36 | Correct | 46 ms | 1380 KB | Output is correct |
37 | Correct | 47 ms | 1260 KB | Output is correct |
38 | Correct | 46 ms | 1260 KB | Output is correct |
39 | Correct | 46 ms | 1380 KB | Output is correct |
40 | Correct | 45 ms | 1380 KB | Output is correct |
41 | Incorrect | 1 ms | 364 KB | Output isn't correct |
42 | Halted | 0 ms | 0 KB | - |