結果

問題 No.1687 What the Heck?
ユーザー ぷらぷら
提出日時 2021-09-24 21:45:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 200,608 KB
実行使用メモリ 5,660 KB
最終ジャッジ日時 2023-09-18 21:04:44
合計ジャッジ時間 3,540 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 21 ms
4,376 KB
testcase_08 AC 30 ms
4,376 KB
testcase_09 AC 20 ms
4,376 KB
testcase_10 AC 14 ms
4,376 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 62 ms
5,392 KB
testcase_13 AC 62 ms
5,380 KB
testcase_14 AC 62 ms
5,464 KB
testcase_15 AC 65 ms
5,472 KB
testcase_16 AC 62 ms
5,528 KB
testcase_17 AC 5 ms
4,376 KB
testcase_18 AC 62 ms
5,660 KB
testcase_19 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>P(N);
    vector<long long>sum(N+1);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
        P[i]--;
        sum[P[i]] = i+1;
    }
    long long ans = 0;
    for(int i = 1; i < N; i++) {
        ans = max(ans,sum[i-1]-sum[i]);
        sum[i] += sum[i-1];
    }
    cout << ans << endl;
}
0