結果
| 問題 | No.3456 Common Difference is D |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-02 07:29:37 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 503 bytes |
| 記録 | |
| コンパイル時間 | 2,473 ms |
| コンパイル使用メモリ | 186,260 KB |
| 実行使用メモリ | 22,600 KB |
| 最終ジャッジ日時 | 2026-10-02 07:29:50 |
| 合計ジャッジ時間 | 10,473 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 TLE * 1 -- * 5 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
int main(){
int N, D;
cin >> N >> D;
vector<int> A(N);
map<int, vector<int>> I;
for (int i = 0; i < N; i++){
cin >> A[i];
I[A[i]].push_back(i);
}
ll ans = 0;
for (int i = 0; i < N; i++){
for (int j : I[A[i]+D]){
ans += I[A[i]+2*D].end()-upper_bound(I[A[i]+2*D].begin(), I[A[i]+2*D].end(), j);
}
}
cout << ans << endl;
}