結果

問題 No.1687 What the Heck?
ユーザー baitoniochitabaitoniochita
提出日時 2021-09-24 22:41:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,269 bytes
コンパイル時間 4,047 ms
コンパイル使用メモリ 232,040 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2023-09-18 21:51:08
合計ジャッジ時間 5,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 27 ms
4,556 KB
testcase_08 AC 38 ms
5,576 KB
testcase_09 AC 27 ms
4,776 KB
testcase_10 AC 18 ms
4,380 KB
testcase_11 AC 19 ms
4,380 KB
testcase_12 AC 77 ms
7,844 KB
testcase_13 AC 77 ms
7,836 KB
testcase_14 AC 76 ms
7,836 KB
testcase_15 AC 77 ms
7,716 KB
testcase_16 AC 77 ms
7,504 KB
testcase_17 AC 6 ms
4,380 KB
testcase_18 AC 78 ms
7,792 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ld = long double;
#define _GLIBCXX_DEBUG
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
using ll = long long;
long long MOD=1000000007;
ll MOD2=998244353;
const ll INF=0x1fffffffffffffff;
using Graph = vector<vector<int>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
int main() {
   ll N;
   cin>>N;
  ll ans=0;
  vec(ll,dp,N);
  vector<pair<ll, ll>> p(N);
  dp[0]=0;
  
rep1(N){
    ll a;
    cin >> a ;
    p.at(i) = make_pair(a, i+1); 
  }
 
  sort(p.begin(), p.end());
  dp[1]=p[0].second-p[1].second;
  ans=max(ans,dp[1]);
    for(ll i=1;i<=N-2;i++){
      dp[i+1]=dp[i]+2*p[i].second-p[i+1].second;
      ans=max(ans,dp[i+1]);
    }
    
    
cout<<ans<<endl;
}
                            


0