結果

問題 No.3257 +|+
ユーザー 沙耶花
提出日時 2025-09-05 22:19:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 915 bytes
コンパイル時間 4,196 ms
コンパイル使用メモリ 253,972 KB
実行使用メモリ 15,944 KB
最終ジャッジ日時 2025-09-05 22:19:18
合計ジャッジ時間 9,043 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000005
#define Inf64 1000000000000000001LL


int main(){
	
	int n;
	cin>>n;
	vector<long long> a(n);
	rep(i,n)cin>>a[i];
	
	long long ans = 0;
	for(long long i=2;i<=1700;i++){
		for(long long j=1;j<i;j++){
			int ii = j-1,jj = (i-j)-1;
			if(jj>=n)continue;
			if(ii>=jj)break;
			if((a[ii]+a[jj])%i==0&&(a[ii]+a[jj])/i>300){
				ans++;
			}
		}
	}
	for(long long i=1;i<=300;i++){
		vector<long long> t(n);
		rep(j,n){
			t[j] = a[j] - (j+1) * i;
		}
		sort(t.begin(),t.end());
		rep(j,n){
			if(t[j] < 0)continue;
			int d = distance(t.begin(),lower_bound(t.begin(),t.end(),-t[j]));
			while(d<j){
				if(t[d]==-t[j]){
					ans++;
					d++;
				}
				else{
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
}
0