結果
問題 |
No.1687 What the Heck?
|
ユーザー |
![]() |
提出日時 | 2021-09-24 22:12:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 795 bytes |
コンパイル時間 | 1,580 ms |
コンパイル使用メモリ | 162,020 KB |
実行使用メモリ | 5,632 KB |
最終ジャッジ日時 | 2024-07-05 10:43:10 |
合計ジャッジ時間 | 2,562 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 WA * 11 |
ソースコード
# 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(); int N;cin >> N; vi P(N); for(auto &&e : P) cin >> e; //solve(); vector<pii> point(N); rep(i, N){ point[P[i]-1] = make_pair(P[i], i+1); } reverse(all(point)); int ans = 0; int sum = N*(N+1)/2; rep(i, N){ sum -= 2*point[i].second; ans = max(ans, sum); sum += point[i].second; } //output(); cout << ans << endl; }