結果
| 問題 |
No.3257 +|+
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-05 04:42:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 422 ms / 3,000 ms |
| コード長 | 791 bytes |
| コンパイル時間 | 3,601 ms |
| コンパイル使用メモリ | 284,144 KB |
| 実行使用メモリ | 71,492 KB |
| 最終ジャッジ日時 | 2025-09-05 15:05:45 |
| 合計ジャッジ時間 | 14,173 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#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<long long>> C(2*M+1);
for (int i = 1; i <= N; i++) {
for (int d = 1; d <= (A[i] + M) / i; d++) {
C[d].push_back(A[i] - d * i);
}
}
long long ans = 0;
for (int d = 1; d <= (2 * M) / 3; d++) {
sort(C[d].begin(), C[d].end());
int cnt0 = 0;
for (int c : C[d]) {
if (c > 0) break;
if (c == 0) {
cnt0++;
}
else {
ans += upper_bound(C[d].begin(), C[d].end(), -c) - lower_bound(C[d].begin(), C[d].end(), -c);
}
}
ans += (long long)cnt0 * (cnt0 - 1) / 2;
}
cout << ans << endl;
}