結果
| 問題 |
No.2374 ASKT Subsequences
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-07 21:50:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 761 bytes |
| コンパイル時間 | 2,038 ms |
| コンパイル使用メモリ | 174,088 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-21 17:42:44 |
| 合計ジャッジ時間 | 2,876 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for(auto &&v : a) cin >> v;
ll ans = 0;
for(int k = 1; k <= 2000; k++){
vector<vector<ll>> cnt(4, vector<ll>(2001));
int d1 = k + 10;
int d2 = -k;
int d3 = k + 1;
for(int j = n - 1; j >= 0; j--){
cnt[3][a[j]]++;
if(a[j] + d3 <= 2000) cnt[2][a[j]] += cnt[3][a[j] + d3];
if(a[j] + d2 >= 0) cnt[1][a[j]] += cnt[2][a[j] + d2];
if(a[j] + d1 <= 2000) cnt[0][a[j]] += cnt[1][a[j] + d1];
}
ans += accumulate(cnt[0].begin(), cnt[0].end(), 0ll);
}
cout << ans << '\n';
}