結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
ユーザー ococonomy1ococonomy1
提出日時 2024-02-23 21:26:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 2,062 bytes
コンパイル時間 1,064 ms
コンパイル使用メモリ 110,012 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-23 21:27:03
合計ジャッジ時間 3,847 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 27 ms
6,676 KB
testcase_02 AC 24 ms
6,676 KB
testcase_03 AC 24 ms
6,676 KB
testcase_04 AC 24 ms
6,676 KB
testcase_05 AC 25 ms
6,676 KB
testcase_06 AC 25 ms
6,676 KB
testcase_07 AC 25 ms
6,676 KB
testcase_08 AC 25 ms
6,676 KB
testcase_09 AC 25 ms
6,676 KB
testcase_10 AC 25 ms
6,676 KB
testcase_11 AC 25 ms
6,676 KB
testcase_12 AC 25 ms
6,676 KB
testcase_13 AC 25 ms
6,676 KB
testcase_14 AC 24 ms
6,676 KB
testcase_15 AC 25 ms
6,676 KB
testcase_16 AC 24 ms
6,676 KB
testcase_17 AC 25 ms
6,676 KB
testcase_18 AC 25 ms
6,676 KB
testcase_19 AC 25 ms
6,676 KB
testcase_20 AC 25 ms
6,676 KB
testcase_21 AC 25 ms
6,676 KB
testcase_22 AC 25 ms
6,676 KB
testcase_23 AC 25 ms
6,676 KB
testcase_24 AC 24 ms
6,676 KB
testcase_25 AC 24 ms
6,676 KB
testcase_26 AC 25 ms
6,676 KB
testcase_27 AC 24 ms
6,676 KB
testcase_28 AC 24 ms
6,676 KB
testcase_29 AC 25 ms
6,676 KB
testcase_30 AC 25 ms
6,676 KB
testcase_31 AC 24 ms
6,676 KB
testcase_32 AC 25 ms
6,676 KB
testcase_33 AC 24 ms
6,676 KB
testcase_34 AC 25 ms
6,676 KB
testcase_35 AC 39 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

template <typename T> vector<T> getvec(int n,T val){
    vector<T> ans(n);
    for(int i = 0; i < n; i++){
        cin >> ans[i];
        ans[i] += val;
    }
    return ans;
}

template <typename T> void printvec(vector<T> const& a,T val){
    int n = a.size();
    for(int i = 0; i < n; i++){
        cout << (a[i] + val);
        if(i != n - 1)cout << ' ';
    }
    cout << '\n';
}

#define MULTI_TEST_CASE true 
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    int n;
    cin >> n;
    vector<ll> a = getvec<ll>(n,0);
    ll ans = 0;
    for(int i = 0; i < n - 1; i++){
        ans = max(ans,a[i] - a[i + 1] + 1);
    }
    cout << ans << el;
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0