結果

問題 No.1687 What the Heck?
ユーザー huka_huka
提出日時 2021-09-25 19:53:56
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 1,287 ms
コンパイル使用メモリ 166,948 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-07-05 15:29:12
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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();
  map<int, int> index;
  rep(i, N){
    index[P[i]] = i+1;
  }
  int ans = 0;
  int 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;
}
0