結果
問題 |
No.3257 +|+
|
ユーザー |
![]() |
提出日時 | 2025-09-05 22:22:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,092 bytes |
コンパイル時間 | 4,307 ms |
コンパイル使用メモリ | 254,072 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-05 22:23:28 |
合計ジャッジ時間 | 49,029 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 TLE * 3 |
ソースコード
#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()); long long pre = 0; rep(j,n){ if(t[j] < 0)continue; if(j>0 && t[j-1]==t[j]){ if(t[j]==0){ pre++; ans += pre; } else{ ans += pre; } continue; } pre = 0; int d = distance(t.begin(),lower_bound(t.begin(),t.end(),-t[j])); while(d<j){ if(t[d]==-t[j]){ ans++; pre++; d++; } else{ break; } } } } cout<<ans<<endl; }