結果

問題 No.1687 What the Heck?
ユーザー erbowl
提出日時 2022-08-27 17:15:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 2,066 ms
コンパイル使用メモリ 194,992 KB
最終ジャッジ日時 2025-01-31 06:27:17
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n;
    std::cin >> n;
    ll ans = 0;
    vector<ll> pi(n+1);
    for (int i = 0; i < n; i++) {
        ll p;
        std::cin >> p;
        pi[p] = i+1;
    }
    ll now = n*(n+1)/2;
    for (int i = n; i >= 1; i--) {
        ans = max(ans, now-2*pi[i]);
        now -= i;
    }
    std::cout << ans << std::endl;
}
0