結果

問題 No.1687 What the Heck?
ユーザー atjh16atjh16
提出日時 2021-09-25 14:06:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 1,983 ms
コンパイル使用メモリ 198,472 KB
実行使用メモリ 5,204 KB
最終ジャッジ日時 2023-09-18 23:01:25
合計ジャッジ時間 3,530 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

long long n, p, m = 0, v = 0;
long long u[200001];

int main(){
    cin >> n;
        
    for(long long i = 0; i < n; i++){
        cin >> p;
        u[p] = i + 1;
    }
    
    for(long long i = 1; i < n; i++){
        v = v + u[i];
        m = max(m, v - u[i + 1]);
    }

    cout << m << endl;
}
0