Submission #245813

# Submission time Handle Problem Language Result Execution time Memory
245813 2020-07-07T13:37:10 Z Osama_Alkhodairy Sparklers (JOI17_sparklers) C++17
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
#define ld long double

const int N = 1001;

int n, k, T;
ld dp[N][N];
vector <int> x;

ld calc(ll d, ld t, ld s){
    d /= 2;
    return t - d / s;
}
bool can(int s){
    for(int l = 0 ; l < n ; l++){
        for(int r = l + 1 ; r < n ; r++){
            dp[l][r] = -1;
        }
    }
    dp[k][k] = T;
    for(int len = 2 ; len <= n ; len++){
        for(int l = 0, r = len - 1 ; r < n ; l++, r++){
            if(dp[l + 1][r] >= 0){
                ld new_t = calc(x[l + 1] - x[l], dp[l + 1][r], s);
                if(new_t >= 0){
                    dp[l][r] = max(dp[l][r], new_t + T);
                }
            }
            if(dp[l][r - 1] >= 0){
                ld new_t = calc(x[r] - x[r - 1], dp[l][r - 1], s);
                if(new_t >= 0){
                    dp[l][r] = max(dp[l][r], new_t + T);
                }
            }
        }
    }
    return dp[0][n - 1] >= 0;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k >> T;
    x.resize(n);
    for(auto &i : x) cin >> i;
    k--;
    if(x.back() - x[0] == 0) finish(0);
    int l = 1, r = 1e9;
    while(l <= r){
        int mid = (l + r) / 2;
        if(can(mid)) r = mid - 1;
        else l = mid + 1;
    }
    cout << l << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -