結果

問題 No.2374 ASKT Subsequences
ユーザー kotatsugamekotatsugame
提出日時 2023-07-07 21:32:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 544 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 82,892 KB
実行使用メモリ 191,048 KB
最終ジャッジ日時 2023-09-28 22:30:04
合計ジャッジ時間 4,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 9 ms
6,488 KB
testcase_12 AC 4 ms
4,824 KB
testcase_13 AC 3 ms
4,392 KB
testcase_14 AC 16 ms
9,356 KB
testcase_15 AC 25 ms
12,336 KB
testcase_16 AC 12 ms
7,484 KB
testcase_17 AC 45 ms
19,312 KB
testcase_18 AC 104 ms
37,640 KB
testcase_19 AC 89 ms
33,236 KB
testcase_20 AC 217 ms
70,480 KB
testcase_21 AC 284 ms
86,940 KB
testcase_22 AC 176 ms
59,092 KB
testcase_23 AC 109 ms
37,976 KB
testcase_24 AC 108 ms
38,160 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 544 ms
139,500 KB
testcase_27 AC 7 ms
4,376 KB
testcase_28 AC 59 ms
9,216 KB
testcase_29 AC 310 ms
191,048 KB
testcase_30 AC 116 ms
66,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
#include<cassert>
using namespace std;
map<int,int>L[2000],R[2000];
int N,A[2000];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i];
	for(int i=1;i<N;i++)
	{
		L[i]=L[i-1];
		L[i][A[i-1]]++;
	}
	for(int i=N-2;i>=0;i--)
	{
		R[i]=R[i+1];
		R[i][A[i+1]]++;
	}
	long ans=0;
	for(int i=1;i<N;i++)for(int j=i+1;j+1<N;j++)
	{
		int k=A[i]-A[j];
		if(k<=0)continue;
		int l=0,r=0;
		if(L[i].find(A[i]-k-10)!=L[i].end())l=L[i][A[i]-k-10];
		if(R[j].find(A[j]+k+1)!=R[j].end())r=R[j][A[j]+k+1];
		ans+=l*r;
	}
	cout<<ans<<endl;
}
0