Submission #878967

# Submission time Handle Problem Language Result Execution time Memory
878967 2023-11-25T20:05:19 Z eitanelb Sparklers (JOI17_sparklers) C++14
50 / 100
153 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool ok(int n, int k, vector<int>&v, ll m){
    bool dp[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) dp[i][j]=0;
    dp[k-1][k-1]=1;
    for(int sz=2;sz<=n;sz++){
        for(int i=0;i+sz-1 < n;i++){
            if(((v[i+sz-1]-v[i]) <= 2*m*(sz-1)) && (dp[i][i+sz-2] || dp[i+1][i+sz-1])) dp[i][i+sz-1]=1;
        }
    }
    //cout<<m<<' '<<dp[0][n-1]<<endl;
    return dp[0][n-1];
}
int func(int n, int k, int t, vector<int>&v){
    int s=0, e=1e9, m;
    while(e>s){
        m = (e+s)/2;
        if(ok(n,k,v,m)) e=m;
        else s=m+1;
    }
    return (s+t-1)/t;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    int n,k,t;
    cin>>n>>k>>t;
    vector<int> v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    
    int res = func(n,k,t,v);
    
    cout<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 16 ms 860 KB Output is correct
23 Correct 9 ms 780 KB Output is correct
24 Correct 15 ms 860 KB Output is correct
25 Correct 32 ms 1456 KB Output is correct
26 Correct 26 ms 1368 KB Output is correct
27 Correct 28 ms 1372 KB Output is correct
28 Correct 29 ms 1368 KB Output is correct
29 Correct 31 ms 1368 KB Output is correct
30 Correct 28 ms 1368 KB Output is correct
31 Correct 30 ms 1372 KB Output is correct
32 Correct 29 ms 1668 KB Output is correct
33 Correct 28 ms 1368 KB Output is correct
34 Correct 29 ms 1372 KB Output is correct
35 Correct 26 ms 1368 KB Output is correct
36 Correct 30 ms 1372 KB Output is correct
37 Correct 29 ms 1368 KB Output is correct
38 Correct 29 ms 1368 KB Output is correct
39 Correct 36 ms 1372 KB Output is correct
40 Correct 29 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 16 ms 860 KB Output is correct
23 Correct 9 ms 780 KB Output is correct
24 Correct 15 ms 860 KB Output is correct
25 Correct 32 ms 1456 KB Output is correct
26 Correct 26 ms 1368 KB Output is correct
27 Correct 28 ms 1372 KB Output is correct
28 Correct 29 ms 1368 KB Output is correct
29 Correct 31 ms 1368 KB Output is correct
30 Correct 28 ms 1368 KB Output is correct
31 Correct 30 ms 1372 KB Output is correct
32 Correct 29 ms 1668 KB Output is correct
33 Correct 28 ms 1368 KB Output is correct
34 Correct 29 ms 1372 KB Output is correct
35 Correct 26 ms 1368 KB Output is correct
36 Correct 30 ms 1372 KB Output is correct
37 Correct 29 ms 1368 KB Output is correct
38 Correct 29 ms 1368 KB Output is correct
39 Correct 36 ms 1372 KB Output is correct
40 Correct 29 ms 1372 KB Output is correct
41 Runtime error 153 ms 262144 KB Execution killed with signal 9
42 Halted 0 ms 0 KB -