結果

問題 No.2374 ASKT Subsequences
ユーザー as277575as277575
提出日時 2023-07-07 22:50:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,786 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 1,291 ms
コンパイル使用メモリ 130,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 00:25:56
合計ジャッジ時間 18,499 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 9 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 11 ms
4,376 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 12 ms
4,376 KB
testcase_07 AC 48 ms
4,376 KB
testcase_08 AC 31 ms
4,376 KB
testcase_09 AC 43 ms
4,376 KB
testcase_10 AC 114 ms
4,380 KB
testcase_11 AC 296 ms
4,380 KB
testcase_12 AC 197 ms
4,380 KB
testcase_13 AC 150 ms
4,380 KB
testcase_14 AC 384 ms
4,376 KB
testcase_15 AC 479 ms
4,376 KB
testcase_16 AC 339 ms
4,376 KB
testcase_17 AC 673 ms
4,380 KB
testcase_18 AC 929 ms
4,376 KB
testcase_19 AC 896 ms
4,376 KB
testcase_20 AC 1,328 ms
4,376 KB
testcase_21 AC 1,453 ms
4,384 KB
testcase_22 AC 1,256 ms
4,380 KB
testcase_23 AC 930 ms
4,376 KB
testcase_24 AC 935 ms
4,376 KB
testcase_25 AC 151 ms
4,376 KB
testcase_26 AC 1,724 ms
4,376 KB
testcase_27 AC 297 ms
4,376 KB
testcase_28 AC 390 ms
4,380 KB
testcase_29 AC 1,786 ms
4,380 KB
testcase_30 AC 918 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bit>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template<typename T, typename U>
ostream& operator<< (ostream& o, const pair<T, U>& p) {
  o << "<" << p.first << ", " << p.second << ">";
  return o;
}

template <typename T>
ostream& operator<< (ostream& o, const vector<T>& v) {
 for (const auto& x : v) o << x << " ";
 return o;
}

ostream& operator<<(ostream& o, const unordered_map<long long, long long>& m) {
  o << "{";
  for (const auto& [k, v] : m)
    o << " " << k << ": " << v << ",";
  o << "}";
  return o;
}

template <typename T>
istream& operator>> (istream& i, vector<T>& v) {
  for (auto& x : v) i >> x;
  return i;
}

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  long long r = 0;
  for (int k = 1; k <= 2000; ++k) {
    vector<unordered_map<int, int>> d(3);
    for (int ax : a) {
      d[0][ax]++;
      d[1][ax] += d[0][ax - k - 10];
      d[2][ax] += d[1][ax + k];
      r += d[2][ax - k - 1];
    }
  }
  // c[i] * c[i + k + 10] * c[i + 10] * c[i + k + 11];
  cout << r << endl;
  return 0;
}

0