結果
問題 |
No.3257 +|+
|
ユーザー |
|
提出日時 | 2025-09-05 22:20:08 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,129 bytes |
コンパイル時間 | 3,564 ms |
コンパイル使用メモリ | 284,044 KB |
実行使用メモリ | 15,940 KB |
最終ジャッジ日時 | 2025-09-05 22:20:38 |
合計ジャッジ時間 | 8,479 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 TLE * 1 -- * 28 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { cin.tie(nullptr) -> sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; const int MAXA = 200000; const int MAX_SUM = 2*MAXA; const int B = 700; const int LIM = MAX_SUM/B; ll ans = 0; for (int m = 1; m <= B; ++m) { map<int,int> cnt; rep(j, n) cnt[a[j]-m*(j+1)]++; rep(i, n) { auto it = cnt.find(a[i]-m*(i+1)); if (it != cnt.end()) { if (--(it->second) == 0) cnt.erase(it); } auto it2 = cnt.find(m*(i+1)-a[i]); if (it2 != cnt.end()) ans += it2->second; } } rep(i, n) { int maxj = min(n, LIM-i); if (maxj <= i) continue; for (int j = i+1; j <= maxj; ++j) { int s = i+j+2; int sum = a[i]+a[j]; if (sum%s == 0) { if (sum/s > B) ++ans; } } } cout << ans << "\n"; return 0; }