結果
問題 | No.1687 What the Heck? |
ユーザー |
![]() |
提出日時 | 2021-09-25 22:04:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 1,295 ms |
コンパイル使用メモリ | 166,376 KB |
実行使用メモリ | 16,384 KB |
最終ジャッジ日時 | 2024-07-05 15:31:10 |
合計ジャッジ時間 | 3,264 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
# ifndef ONLINE_JUDGE # define _GLIBCXX_DEBUG # endif #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vvi = vector<vector<int>>; using pii = pair<int, int>; # define rep(i, n) for(int i = 0; i < (int)(n); ++i) # define all(v) v.begin(), v.end() int main(){ constexpr char endl = '\n'; ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); //input(); ll N;cin >> N; vi P(N); for(auto &&e : P) cin >> e; //solve(); map<ll, ll> index; rep(i, N){ index[P[i]] = i+1; } ll ans = 0; ll sum = (N*(N+1))/2; for(int i = N; 1 <= i; --i){ ans = max(ans, sum-2*index[i]); sum -= index[i]; } //output(); cout << ans << endl; }