結果
問題 | No.1687 What the Heck? |
ユーザー | huka_huka |
提出日時 | 2021-09-25 22:04:07 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 215 ms / 2,000 ms |
コード長 | 741 bytes |
コンパイル時間 | 1,790 ms |
コンパイル使用メモリ | 152,824 KB |
実行使用メモリ | 16,324 KB |
最終ジャッジ日時 | 2023-09-19 02:44:22 |
合計ジャッジ時間 | 4,282 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,380 KB |
testcase_07 | AC | 58 ms
7,804 KB |
testcase_08 | AC | 88 ms
9,756 KB |
testcase_09 | AC | 57 ms
7,824 KB |
testcase_10 | AC | 34 ms
6,376 KB |
testcase_11 | AC | 37 ms
6,588 KB |
testcase_12 | AC | 215 ms
16,292 KB |
testcase_13 | AC | 214 ms
16,324 KB |
testcase_14 | AC | 208 ms
16,288 KB |
testcase_15 | AC | 211 ms
16,248 KB |
testcase_16 | AC | 204 ms
15,904 KB |
testcase_17 | AC | 9 ms
4,380 KB |
testcase_18 | AC | 215 ms
16,292 KB |
testcase_19 | AC | 2 ms
4,380 KB |
ソースコード
# 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; }