結果
問題 |
No.3257 +|+
|
ユーザー |
![]() |
提出日時 | 2025-06-14 18:10:37 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 760 bytes |
コンパイル時間 | 3,076 ms |
コンパイル使用メモリ | 288,232 KB |
実行使用メモリ | 38,852 KB |
最終ジャッジ日時 | 2025-09-05 15:02:20 |
合計ジャッジ時間 | 12,597 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 RE * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; int M = 200'000; int A[N+1]; for (int i = 1; i <= N; i++) cin >> A[i]; vector<vector<int>> C(M+1); for (int i = 1; i <= N; i++) { int d = 1; while(A[i] - d * i >= -M) { C[d].push_back(A[i] - d * i); d++; } } long long ans = 0; for (int d = 1; d <= M; d++) { map<int, long long> cnt; for (int x : C[d]) cnt[x]++; for (auto[x, c] : cnt) { if (x == 0) { ans += c * (c-1) / 2; } if (x < 0) { if (cnt.contains(-x)) ans += c * cnt[-x]; } } } cout << ans << endl; }