結果

問題 No.2374 ASKT Subsequences
ユーザー iwaiwaiwaispiwaiwaiwaisp
提出日時 2023-07-07 23:52:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 576 ms / 2,000 ms
コード長 1,992 bytes
コンパイル時間 5,021 ms
コンパイル使用メモリ 232,612 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 01:36:36
合計ジャッジ時間 7,735 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 10 ms
4,380 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 18 ms
4,376 KB
testcase_15 AC 29 ms
4,376 KB
testcase_16 AC 13 ms
4,376 KB
testcase_17 AC 51 ms
4,380 KB
testcase_18 AC 126 ms
4,376 KB
testcase_19 AC 106 ms
4,376 KB
testcase_20 AC 250 ms
4,380 KB
testcase_21 AC 319 ms
4,380 KB
testcase_22 AC 198 ms
4,376 KB
testcase_23 AC 130 ms
4,380 KB
testcase_24 AC 130 ms
4,380 KB
testcase_25 AC 8 ms
4,376 KB
testcase_26 AC 576 ms
4,380 KB
testcase_27 AC 25 ms
4,376 KB
testcase_28 AC 191 ms
4,376 KB
testcase_29 AC 307 ms
4,380 KB
testcase_30 AC 125 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <atcoder/all>
#include <functional> 
using namespace atcoder;
using namespace std;

#define reps(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define repe(i,n) for(auto i : n)

#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による

#define F first
#define S second
#define ll long long

#define cYes cout << "Yes" << endl;
#define cNo cout << "No" << endl;

#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;
#define coutALL2d(vv) for(const auto& v : vv){for(const auto& e : v){cout << e << " ";}cout << endl;}
#define cout2(x,y) cout << x << " " << y << endl;
#define cout3(x,y,z) cout << x << " " << y << " " << z << endl;
#define cout4(x,y,z,p) cout << x << " " << y << " " << z <<" " << p << endl;

#define vmax(x) *max_element(x.begin(), x.end())
#define vmin(x) *min_element(x.begin(), x.end())

#define vi vector<int>
#define vvi vector<vector<int> >
#define vll vector<long long>
#define vvll vector<vector<long long> >

using namespace std;
using namespace atcoder;


int main() {
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];

  map<int,ll> le;
  ll sm = 0;
rep(i,n){
  map<int,ll> ri;
  reps(j,i+1,n){
    ri[a[j]]++;
  }
  reps(j,i+1,n){
    ri[a[j]]--;
    auto ite = ri.find(a[i]+1);
    auto ite2 = le.find(a[j]-10);
    if(ite != ri.end()){
      //cout3("ri",a[i]+1,ite->S)
    }
    if(ite2 != le.end()){
      //cout3("le",a[j]-10,ite2->S)
    }

    if(ite != ri.end() && ite2 != le.end() && a[i]-a[j] > 0&&a[i]-a[j] == a[i]+1 - a[j]-1){
      //cout4(a[i],a[j],ite->S,ite2->S);
      sm += ite->S * ite2->S;
    }
  }
  le[a[i]]++;
}
cout << sm << endl;
}
0