結果
問題 |
No.2374 ASKT Subsequences
|
ユーザー |
![]() |
提出日時 | 2023-07-09 07:13:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 1,808 ms |
コンパイル使用メモリ | 197,464 KB |
最終ジャッジ日時 | 2025-02-15 09:17:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector<int> A(n); rep(i,n) cin>>A[i]; vector<vector<int>> L(n,vector<int> (2001)),R(n,vector<int> (2001)); L[0][A[0]]=1,R[n-1][A[n-1]]=1; for(int i=1;i<n;i++){ for(int j=1;j<=2000;j++) L[i][j]=L[i-1][j]; L[i][A[i]]++; } for(int i=n-2;i>=0;i--){ for(int j=1;j<=2000;j++) R[i][j]=R[i+1][j]; R[i][A[i]]++; } ll ans=0; for(int i=1;i<n-2;i++){ for(int j=i+1;j<n-1;j++){ if(A[i]<=A[j]) continue; if(A[j]-10<1) continue; if(A[i]+1>2000) continue; ans+=(ll)L[i-1][A[j]-10]*R[j+1][A[i]+1]; } } cout<<ans<<endl; return 0; }