結果
問題 |
No.3257 +|+
|
ユーザー |
![]() |
提出日時 | 2025-09-05 22:16:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 920 bytes |
コンパイル時間 | 4,625 ms |
コンパイル使用メモリ | 255,736 KB |
実行使用メモリ | 12,580 KB |
最終ジャッジ日時 | 2025-09-05 22:16:56 |
合計ジャッジ時間 | 29,614 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 TLE * 3 -- * 19 |
ソースコード
#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<=800;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>800){ ans++; } } } for(long long i=1;i<=800;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])); int r = distance(t.begin(),upper_bound(t.begin(),t.end(),-t[j])); r = min(r,j); ans += r - d; } } cout<<ans<<endl; }