結果

問題 No.2374 ASKT Subsequences
ユーザー shobonvipshobonvip
提出日時 2023-07-07 22:44:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 970 bytes
コンパイル時間 4,369 ms
コンパイル使用メモリ 260,612 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-29 00:20:05
合計ジャッジ時間 5,917 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 4 ms
4,380 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 8 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 7 ms
4,380 KB
testcase_25 AC 7 ms
4,376 KB
testcase_26 AC 22 ms
4,376 KB
testcase_27 AC 22 ms
4,380 KB
testcase_28 AC 16 ms
4,376 KB
testcase_29 AC 17 ms
4,376 KB
testcase_30 AC 16 ms
4,376 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,n+1){
		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