結果

問題 No.2374 ASKT Subsequences
ユーザー SSRSSSRS
提出日時 2023-07-07 21:35:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 666 bytes
コンパイル時間 1,586 ms
コンパイル使用メモリ 168,808 KB
実行使用メモリ 19,188 KB
最終ジャッジ日時 2023-09-28 22:34:06
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
18,604 KB
testcase_01 AC 13 ms
18,620 KB
testcase_02 AC 13 ms
18,560 KB
testcase_03 AC 13 ms
18,556 KB
testcase_04 AC 13 ms
18,564 KB
testcase_05 AC 14 ms
19,012 KB
testcase_06 AC 14 ms
18,944 KB
testcase_07 AC 14 ms
19,012 KB
testcase_08 AC 13 ms
18,616 KB
testcase_09 AC 13 ms
19,136 KB
testcase_10 AC 14 ms
19,188 KB
testcase_11 AC 15 ms
18,564 KB
testcase_12 AC 14 ms
18,560 KB
testcase_13 AC 14 ms
18,620 KB
testcase_14 AC 15 ms
19,012 KB
testcase_15 AC 16 ms
18,560 KB
testcase_16 AC 15 ms
18,616 KB
testcase_17 AC 17 ms
18,612 KB
testcase_18 AC 19 ms
18,948 KB
testcase_19 AC 18 ms
18,564 KB
testcase_20 AC 23 ms
18,632 KB
testcase_21 AC 25 ms
18,876 KB
testcase_22 AC 21 ms
18,620 KB
testcase_23 AC 18 ms
18,572 KB
testcase_24 AC 19 ms
18,956 KB
testcase_25 AC 16 ms
19,008 KB
testcase_26 AC 31 ms
18,560 KB
testcase_27 AC 20 ms
18,952 KB
testcase_28 AC 25 ms
18,944 KB
testcase_29 AC 33 ms
19,008 KB
testcase_30 AC 22 ms
19,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i]--;
  }
  vector<int> cnt(2000, 0);
  vector<vector<int>> cnt2(2000, vector<int>(2000, 0));
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--){
    for (int j = 0; j < i; j++){
      int k = A[i] - A[j] - 10;
      if (k > 0){
        int c = A[i] - k;
        int d = c + k + 1;
        if (0 <= c && c < 2000 && 0 <= d && d < 2000){
          ans += cnt2[c][d];
        }
      }
    }
    for (int j = 0; j < 2000; j++){
      cnt2[A[i]][j] += cnt[j];
    }
    cnt[A[i]]++;
  }
  cout << ans << endl;
}
0