結果

問題 No.1687 What the Heck?
ユーザー Nzt3
提出日時 2022-09-29 19:49:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 193,040 KB
最終ジャッジ日時 2025-02-07 18:22:05
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>P(N);
  for(int i=0;i<N;i++){
    int a;cin>>a;
    P[a-1]=i+1;
  }
  long long ans=0,s=0;
  for(int i=0;i<N-1;i++){
    s+=P[i];
    ans=max(ans,s-P[i+1]);
  }
  cout<<ans<<'\n';
}
0