結果

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

ソースコード

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=1e12;
        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