結果

問題 No.3257 +|+
ユーザー t98slider
提出日時 2025-09-05 23:51:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 2,251 ms
コンパイル使用メモリ 195,508 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2025-09-05 23:51:38
合計ジャッジ時間 7,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 8 RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    constexpr int r = 400000;
    vector<int> A(2 * r + 1);
    auto cnt = A.begin() + (2 * r);
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto &&v : a) cin >> v;
    auto b = a.begin() - 1;
    ll ans = 0;
    for(int d = 1; d <= 133333; d++){
        int m = min(n, r / d + 1);
        for(int i = 1; i <= m; i++){
            b[i] -= i;
            ans += cnt[-b[i]];
            cnt[b[i]]++;
        }
        for(int i = 1; i <= m; i++) cnt[b[i]]--;
    }
    cout << ans << '\n';
}
0