結果
問題 | No.2374 ASKT Subsequences |
ユーザー |
![]() |
提出日時 | 2023-07-11 10:11:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 465 ms |
コンパイル使用メモリ | 41,984 KB |
実行使用メモリ | 32,856 KB |
最終ジャッジ日時 | 2024-09-13 00:11:19 |
合計ジャッジ時間 | 1,540 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
/* -*- coding: utf-8 -*- * * 2374.cc: No.2374 ASKT Subsequences - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 2000; const int MAX_A = 2000; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N]; ll dp1[MAX_A], dp2[MAX_A][MAX_A], dp3[MAX_A]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i), as[i]--; // a2=a1+k+10, a3=a1+10, a4=a1+k+11=a2+1 ll dp4 = 0; for (int i = 0; i < n; i++) { int ai = as[i]; if (ai > 0) dp4 += dp3[ai - 1]; if (ai >= 10) for (int aj = 0; aj < MAX_A; aj++) dp3[aj] += dp2[ai - 10][aj]; for (int aj = 0; aj < ai - 10; aj++) dp2[aj][ai] += dp1[aj]; dp1[ai]++; } printf("%lld\n", dp4); return 0; }