답안 #157763

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157763 2019-10-12T19:54:48 Z giorgikob Sparklers (JOI17_sparklers) C++14
0 / 100
2 ms 256 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

const int N = 1e6+10;

double A[N];

int n,k;

double T;

int ans;

bool check(double V){
    //cout<<V<<endl;
    int l = k - 1, r = k + 1;
    
    double sl = 0, sr = 0; 
    double reserveT = T;
    
    while(l>=1 || r<=n){
        
        double s1 = (l>=1) ? A[k] - A[l] - sl : 1e9;
        double s2 = (r<=n) ? A[r] - A[k] - sr : 1e9;
        //cout<<s1<<" "<<s2<<"----"<<sl<<" "<<sr<<endl;
        if(s1 <= s2){
            if(reserveT >= s1/(2*V)){
                reserveT -= s1/(2*V);
                reserveT += T;
                sl += s1;
                l--;
            } else {
                return false;
            }
        } else {
            if(reserveT >= s2/(2*V)){
                reserveT -= s2/(2*V);
                reserveT += T;
                sr += s2;
                r++;
            } else {
                return false;
            }
        }
        
    }
    
    return true;
    
}

int main(){
    
    cin>>n>>k>>T;
    
    for(int i=1;i<=n;i++){
        cin>>A[i];
    }
    
    int l = 1, r = 100;
    
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid, r = mid-1; 
        } else {
            l = mid+1;
        }
    }
    
    cout<<ans<<endl;
}



# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -