結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
コンテスト
ユーザー vjudge1
提出日時 2025-11-20 16:25:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 2,955 ms
コンパイル使用メモリ 278,104 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2025-11-20 16:25:20
合計ジャッジ時間 5,726 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef ONPC
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<pair<ll,ll>> vpi;
typedef pair<ll,ll> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define popcount __builtin_popcountll
#define forn(i,a,b) for (ll i = a; i < b; i++)

bool check(vi &arr,ll x){
    forn(i,0,arr.size()-1){
        if(arr[i]+((i+1)*x)>=arr[i+1]+((i+2)*x)){
            // cout<<arr[i]+((i+1)*x)<<" ";
            // cout<<arr[i+1]+((i+2)*x)<<"\n";
            return false;
            
        }
    }
    return true;
}

void solve(){
    ll n;cin>>n;
    vi arr(n);
    ll mx=0;
    forn(i,0,n){
        cin>>arr[i];
        mx=max(mx,arr[i]);
    }    
    // forn(i,0,n)cout<<arr[i]<<" ";
    ll ans=mx;
    ll l=0,r=1e9;
    while(l<=r){
        ll mid=l+(r-l)/2;
        if(check(arr,mid)){
            ans=mid;
            r=mid-1;
        }
        else{
            l=mid+1;
        }
    }
    cout<<ans<<"\n";
}                       
    
    

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t=1;
    cin >> t;
    forn(i,0,t){
        solve();
    }
    #ifdef ONPC
    cerr << endl
         << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
    #endif
}
0