Submission #157764

# Submission time Handle Problem Language Result Execution time Memory
157764 2019-10-12T19:55:32 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;
                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 = 1e9;
    
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid)){
            ans = mid, r = mid-1; 
        } else {
            l = mid+1;
        }
    }
    
    cout<<ans<<endl;
}



# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 128 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 128 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 252 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 252 KB Output is correct
6 Correct 2 ms 128 KB Output is correct
7 Incorrect 2 ms 376 KB Output isn't correct
8 Halted 0 ms 0 KB -