답안 #157765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157765 2019-10-12T20:02:46 Z giorgikob Sparklers (JOI17_sparklers) C++14
0 / 100
2 ms 376 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){
    
    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<<sl<<" "<<sr<<endl;
        if(s1 <= s2){
            if(reserveT >= s1/(2*V)){
                reserveT -= s1/(2*V);
                reserveT += T;
                if(reserveT>=1e9)return true;
                sl += s1;
                l--;
            } else {
                return false;
            }
        } else {
            if(reserveT >= s2/(2*V)){
                reserveT -= s2/(2*V);
                reserveT += T;
                if(reserveT>=1e9)return true;
                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 = 1e9;
    
    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 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -