結果
問題 | No.1687 What the Heck? |
ユーザー |
|
提出日時 | 2022-08-27 17:16:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 2,121 ms |
コンパイル使用メモリ | 195,096 KB |
最終ジャッジ日時 | 2025-01-31 06:27:26 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
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 -= pi[i]; } std::cout << ans << std::endl; }