답안 #1080422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080422 2024-08-29T09:44:16 Z isaachew Sparklers (JOI17_sparklers) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
/*
 The sparkler should move in both directions from the initial person after it is lit
 
 If two people meet, they should do so as soon as possible, otherwise it wouldn't make a difference
 
 A path actually depends on the sum of distances of the first and last people from the person with the sparkler
 
 */
int main(){
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    long long n,k,t;
    std::cin>>n>>k>>t;
    k--;
    std::vector<int> places;
    for(int i=0;i<n;i++){
        int a;
        std::cin>>a;
        places.push_back(a);
    }
    long long lower=1,upper=1e9;//min distance a sparkler can burn for
    while(lower+1<upper){
        long long mid=(lower+upper)/2;
        std::vector<std::vector<int>> dp(n,std::vector<int>(n));
        dp[k][k]=1;
        for(int i=0;i<n-1;i++){
            for(int l=0;l+i<n;l++){
                int r=l+i;
                if(dp[l][r]){
                    if(r+1<n&&places[r+1]-places[l]<=mid*(i+1)){
                        dp[l][r+1]=1;
                    }
                    if(l&&places[r]-places[l-1]<=mid*(i+1)){
                        dp[l-1][r]=1;
                    }
                }
            }
        }
        if(dp[0][n-1]){
            upper=mid;
        }else{
            lower=mid;
        }
    }
    //std::cout<<upper<<'\n';
    //upper/=2;//towards each other
    std::cout<<(upper+2*t-1)/(2*t)<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 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 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 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 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 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 Incorrect 0 ms 348 KB Output isn't correct
20 Halted 0 ms 0 KB -