Submission #674246

# Submission time Handle Problem Language Result Execution time Memory
674246 2022-12-23T14:26:14 Z Ahmed57 Sparklers (JOI17_sparklers) C++14
0 / 100
1 ms 312 KB
#include <bits/stdc++.h>

using namespace std;
int n,k;double t;
double arr[100001];

bool check(double mid){
    int l = k-1 , r = k+1;
    double te = t;
    while(l>=0||r<n){
        if(l>=0&&r==n){
            double dis = (arr[l+1]-arr[l])/2;
            double tim = dis/mid;
            if(tim>te)return 0;
            te-=tim;
            te+=t;
            l--;
        }else if(l==-1&&r<n){
            double dis = (arr[r]-arr[r-1])/2;
            double tim = dis/mid;
            if(tim>te)return 0;
            te-=tim;
            te+=t;
            r++;
        }else{
            if(arr[r]-arr[r-1]<arr[l+1]-arr[l]){
                double dis = (arr[r]-arr[r-1])/2;
                double tim = dis/mid;
                if(tim>te)return 0;
                te-=tim;
                te+=t;
                r++;
            }else{
                double dis = (arr[l+1]-arr[l])/2;
                double tim = dis/mid;
                if(tim>te)return 0;
                te-=tim;
                te+=t;
                l--;
            }
        }
    }
    return 1;
}
int main(){
    cin>>n>>k>>t;
    k--;
    for(int i = 0;i<n;i++)cin>>arr[i];
    sort(arr,arr+n);
    int l = 0 , r = 1e9 , ans = 0;
    while(l<=r){
        int mid = (l+r)/2;
        if(check(mid)){
            r = mid-1;
            ans = mid;
        }else l = mid+1;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Incorrect 0 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -