結果

問題 No.365 ジェンガソート
ユーザー ふーらくたる
提出日時 2016-07-06 10:31:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 54,596 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-12 20:25:43
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

const int kMAX_N = 100010;

int N;
int a[kMAX_N];

void Solve() {
    int ans = 0, next_num = 1;
    for (int i = 0; i < N; i++) {
        if (a[i] < next_num) continue;
        ans += a[i] - next_num;
        next_num = a[i] + 1;
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    Solve();

    return 0;
}
0