結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
baitoniochita
|
| 提出日時 | 2021-09-24 22:41:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 2,000 ms |
| コード長 | 1,269 bytes |
| コンパイル時間 | 3,222 ms |
| コンパイル使用メモリ | 235,008 KB |
| 実行使用メモリ | 8,064 KB |
| 最終ジャッジ日時 | 2024-07-05 11:02:26 |
| 合計ジャッジ時間 | 4,546 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#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;
}
baitoniochita