結果

問題 No.3257 +|+
ユーザー 蜜蜂
提出日時 2025-09-05 21:54:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,672 bytes
コンパイル時間 3,641 ms
コンパイル使用メモリ 292,628 KB
実行使用メモリ 30,372 KB
最終ジャッジ日時 2025-09-05 21:55:04
合計ジャッジ時間 8,576 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

// g++-14 1.cpp -std=c++20 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;

#include <atcoder/math>
#include <atcoder/modint>
using namespace atcoder;

using ll = long long;
using ld = long double;
 
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

random_device seed;
mt19937_64 randint(seed());

ll grr(ll mi, ll ma) { // [mi, ma)
    return mi + randint() % (ma - mi);
}

int sq = 400;

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;cin>>n;
  vi a(n+1,0);
  rep(i,1,n+1){
    cin>>a[i];
  }

  ll ans=0;

  rep(x,1,sq+1){
    // Ai + Aj = x (i + j)
    map<int,int> mp;
    rep(i,1,n+1){
      ll tar=a[i]-x*i;
      ans+=mp[-tar];
      mp[tar]++;
    }
  }

  int lim=min(1010,n);
  rep(i,1,lim+1){
    rep(j,i+1,lim+1){
      if((a[i]+a[j])%(i+j)==0){
        ll x=(a[i]+a[j])/(i+j);
        if(x>sq)ans++;
      }
    }
  }

  cout<<ans<<endl;
}
0