結果

問題 No.2374 ASKT Subsequences
ユーザー random contestantrandom contestant
提出日時 2023-07-07 22:50:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 4,415 ms
コンパイル使用メモリ 263,440 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 00:25:38
合計ジャッジ時間 6,176 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 10 ms
4,376 KB
testcase_02 AC 11 ms
4,376 KB
testcase_03 AC 10 ms
4,376 KB
testcase_04 AC 10 ms
4,380 KB
testcase_05 AC 11 ms
4,376 KB
testcase_06 AC 10 ms
4,380 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 10 ms
4,376 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 AC 12 ms
4,376 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 11 ms
4,380 KB
testcase_14 AC 13 ms
4,376 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 13 ms
4,380 KB
testcase_17 AC 15 ms
4,376 KB
testcase_18 AC 18 ms
4,376 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 20 ms
4,376 KB
testcase_22 AC 19 ms
4,380 KB
testcase_23 AC 18 ms
4,376 KB
testcase_24 AC 17 ms
4,376 KB
testcase_25 AC 16 ms
4,376 KB
testcase_26 AC 27 ms
4,376 KB
testcase_27 AC 23 ms
4,376 KB
testcase_28 AC 21 ms
4,376 KB
testcase_29 AC 22 ms
4,376 KB
testcase_30 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll,ll>;
#define pb push_back
#define int long long
#define double long double
#define INF (ll) 3e18
// Ctrl + Shift + B コンパイル
// Ctrl + C 中断
// ./m 実行


signed main(){
  int n; cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  // 制約的にはKの全探索をしてほしそう
  auto check = [&](int x) -> bool {
    if (x < 1) return false;
    if (x > 2000) return false;
    return true;
  };
  int ans = 0;
  rep(k, 2010){
    if (k == 0) continue;
    vvl dp(4, vl(2001));
    rep(i, n){
      if (check(a[i]-k-1)) dp[3][a[i]] += dp[2][a[i]-k-1];
      if (check(a[i]+k)) dp[2][a[i]] += dp[1][a[i]+k];
      if (check(a[i]-k-10)) dp[1][a[i]] += dp[0][a[i]-k-10];
      dp[0][a[i]]++;
    }
    for(auto x : dp[3]) ans += x;
  }
  cout << ans << endl;
}

// a1 = a1
// a2 = a1 + k + 10
// a3 = a2 - k
// a4 = a3 + k + 1

// a4 = a3 + k + 1 = a2 + 1 = a1 + k + 11
0