Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
623 B
6
Indexable
Never
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>


using namespace std;
int solution(int n, int m, int k, const vector<int> &v){
    for(int i=1;i<n;i++){
        if((m+i<n && v[m+i]>0 && v[m+i]<=k) || (m-i>=0 && v[m-i]>0 && v[m-i]<=k)){
            return i*10;
        }
    }
    return -1;
}

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n; cin>>n;
    int m; cin>>m;
    int k; cin>>k;
    vector<int> v(n);
    for(auto &x: v) cin>>x;
    cout<<solution(n,m-1,k,v)<<endl;
    return 0;
}
Leave a Comment