Submission #581728

# Submission time Handle Problem Language Result Execution time Memory
581728 2022-06-23T05:11:54 Z 반딧불(#8365) Sparklers (JOI17_sparklers) C++17
50 / 100
147 ms 34508 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k;
ll t;
ll arr[100002];
pair<ll, ll> DP[1002][1002];

ll able(ll speed){
    speed*=t;
    for(int i=1; i<=n; i++) for(int j=i; j<=n; j++) DP[i][j].first=1e18, DP[i][j].second=-1e18;
    DP[k][k] = make_pair(arr[k], arr[k]);
    for(int d=1; d<n; d++){
        for(int i=1; i+d<=n; i++){
            int j = i+d;
            if((arr[j]-speed*d) <= (DP[i][j-1].second+speed)){
                DP[i][j].first = min(DP[i][j].first, max(arr[j]-speed*d, DP[i][j-1].first-speed));
                DP[i][j].second = max(DP[i][j].second, DP[i][j-1].second+speed);
            }
            if((arr[i]+speed*d) >= (DP[i+1][j].first-speed)){
                DP[i][j].first = min(DP[i][j].first, DP[i+1][j].first-speed);
                DP[i][j].second = max(DP[i][j].second, min(arr[i]+speed*d, DP[i+1][j].second+speed));
            }
        }
    }
    return DP[1][n].first <= DP[1][n].second;
}

int main(){
    scanf("%d %d %lld", &n, &k, &t);
    for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
    if(arr[1] == arr[n]){
        puts("0");
        return 0;
    }

    ll L = 1, R = 1e9, ANS = 1e9;
    while(L<=R){
        ll MID = (L+R)/2;
        if(able(MID)) ANS = MID, R = MID-1;
        else L = MID+1;
    }
    printf("%lld", ANS);
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d %d %lld", &n, &k, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:34:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 57 ms 7444 KB Output is correct
23 Correct 31 ms 5116 KB Output is correct
24 Correct 52 ms 7384 KB Output is correct
25 Correct 90 ms 11604 KB Output is correct
26 Correct 102 ms 11656 KB Output is correct
27 Correct 94 ms 11604 KB Output is correct
28 Correct 129 ms 11648 KB Output is correct
29 Correct 118 ms 11656 KB Output is correct
30 Correct 102 ms 11620 KB Output is correct
31 Correct 117 ms 11664 KB Output is correct
32 Correct 101 ms 11664 KB Output is correct
33 Correct 133 ms 11664 KB Output is correct
34 Correct 107 ms 11664 KB Output is correct
35 Correct 121 ms 11668 KB Output is correct
36 Correct 88 ms 11664 KB Output is correct
37 Correct 89 ms 11620 KB Output is correct
38 Correct 147 ms 11664 KB Output is correct
39 Correct 118 ms 11652 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 316 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 57 ms 7444 KB Output is correct
23 Correct 31 ms 5116 KB Output is correct
24 Correct 52 ms 7384 KB Output is correct
25 Correct 90 ms 11604 KB Output is correct
26 Correct 102 ms 11656 KB Output is correct
27 Correct 94 ms 11604 KB Output is correct
28 Correct 129 ms 11648 KB Output is correct
29 Correct 118 ms 11656 KB Output is correct
30 Correct 102 ms 11620 KB Output is correct
31 Correct 117 ms 11664 KB Output is correct
32 Correct 101 ms 11664 KB Output is correct
33 Correct 133 ms 11664 KB Output is correct
34 Correct 107 ms 11664 KB Output is correct
35 Correct 121 ms 11668 KB Output is correct
36 Correct 88 ms 11664 KB Output is correct
37 Correct 89 ms 11620 KB Output is correct
38 Correct 147 ms 11664 KB Output is correct
39 Correct 118 ms 11652 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Runtime error 78 ms 34508 KB Execution killed with signal 11
42 Halted 0 ms 0 KB -