結果
| 問題 | No.3456 Common Difference is D |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-28 15:44:05 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 508 ms / 2,000 ms |
| コード長 | 829 bytes |
| 記録 | |
| コンパイル時間 | 2,511 ms |
| コンパイル使用メモリ | 224,700 KB |
| 実行使用メモリ | 34,944 KB |
| 最終ジャッジ日時 | 2026-02-28 15:44:14 |
| 合計ジャッジ時間 | 6,181 ms |
|
ジャッジサーバーID (参考情報) |
judge7 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int nmod(int a, int b){
return(((a % b) + b ) % b);
}
bool solve(int x, int n){
bool flag = false;
if(x<n) return false;
string sx = to_string(x);
string sn = to_string(n);
if(x % n == 0) return true;
for(int i=0; i <= sx.length() - sn.length(); i++) if(sx.substr(i, sn.length()) == sn) return true;
return false;
}
int main(){
ll n, d;
cin >> n >> d;
map<ll, ll> headCandidate;
map<ll, ll> bodyCandidate;
map<ll, ll> tailCandidate;
for(int i=0; i<n; i++){
ll a; cin >> a;
headCandidate[a] += 1;
bodyCandidate[a] += headCandidate[a - d];
tailCandidate[a] += bodyCandidate[a - d];
}
ll count = 0;
for(const auto& [key, value] : tailCandidate){
count += value;
}
cout << count << endl;
}