結果

問題 No.2374 ASKT Subsequences
ユーザー shobonvipshobonvip
提出日時 2023-07-07 22:45:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 4,321 ms
コンパイル使用メモリ 260,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 00:20:21
合計ジャッジ時間 6,075 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

typedef modint998244353 mint;
typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

int main(){
	int n; cin >> n;
	vector<int> a(n);
	rep(i,0,n) cin >> a[i];
	ll ans = 0;
	rep(k,1,2001){
		vector<ll> dp0(2001);
		vector<ll> dp1(2001);
		vector<ll> dp2(2001);
		vector<ll> dp3(2001);
		rep(i,0,n){
			// 3
			if (a[i]-k-1 >= 0) dp3[a[i]] += dp2[a[i]-k-1];
			// 2
			if (a[i]+k <= 2000) dp2[a[i]] += dp1[a[i]+k];
			// 1
			if (a[i]-k-10 >= 0) dp1[a[i]] += dp0[a[i]-k-10];
			// 0
			dp0[a[i]] += 1;
		}
		rep(i,0,2001){
			ans += dp3[i];
		}
	}
	cout << ans << endl;
}
0