답안 #166946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
166946 2019-12-04T18:34:44 Z theStaticMind Sparklers (JOI17_sparklers) C++14
0 / 100
3 ms 376 KB
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,k,t;
      cin>>n>>k>>t;
      vector<int> arr;
      for(int i=0;i<n;i++){
            int x;
            cin>>x;
            arr.pb(x);
      }
      int l=0,r=1e10,ans;
      while(l<=r){
            int mid=(l+r)/2;
            int diff=mid*t;
            int L=arr[k];
            int R=arr[k];
            int i=k-1,j=k+1;
            while(i>=0||j<n){
                  if(i>=0&&arr[i]>=L-2*diff){
                        i--;
                        L-=diff*2;
                        R+=diff;
                  }
                  else if(j<n&&arr[j]<=R+2*diff){
                        j++;
                        L-=diff;
                        R+=diff*2;
                  }
                  else break;
            }
            if(i<0&&j>=n){
                  r=mid-1;
                  ans=mid;
            }
            else{
                  l=mid+1;
            }
      }
      cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -