結果
| 問題 | No.2374 ASKT Subsequences | 
| コンテスト | |
| ユーザー |  FplusFplusF | 
| 提出日時 | 2023-07-07 21:57:09 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,366 ms / 2,000 ms | 
| コード長 | 964 bytes | 
| コンパイル時間 | 2,149 ms | 
| コンパイル使用メモリ | 199,160 KB | 
| 最終ジャッジ日時 | 2025-02-15 07:14:34 | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> v(5001);
    rep(i,n){
        cin >> a[i];
        v[a[i]].push_back(i);
    }
    ll ans=0;
    rep(i,n){
        for(ll k=i+2;k<n;k++){
            if(a[i]+10!=a[k]) continue;
            for(ll j=i+1;j<k;j++){
                ll x=a[j]-a[i]-10;
                if(x<=0) continue;
                ans+=(ll)v[a[i]+x+11].size()-(upper_bound(all(v[a[i]+x+11]),k)-v[a[i]+x+11].begin());
            }
        }
    }
    cout << ans << '\n';
}
            
            
            
        