結果
| 問題 | No.2374 ASKT Subsequences | 
| コンテスト | |
| ユーザー |  shobonvip | 
| 提出日時 | 2023-07-07 22:45:16 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 25 ms / 2,000 ms | 
| コード長 | 971 bytes | 
| コンパイル時間 | 4,156 ms | 
| コンパイル使用メモリ | 251,608 KB | 
| 最終ジャッジ日時 | 2025-02-15 08:02:26 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#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;
}
            
            
            
        