結果

問題 No.2374 ASKT Subsequences
ユーザー as277575as277575
提出日時 2023-07-07 22:50:22
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,824 ms / 2,000 ms
コード長 1,326 bytes
コンパイル時間 1,312 ms
コンパイル使用メモリ 132,708 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-21 19:06:41
合計ジャッジ時間 18,490 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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