結果
| 問題 | No.3456 Common Difference is D |
| コンテスト | |
| ユーザー |
U10
|
| 提出日時 | 2026-02-28 15:15:17 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 940 bytes |
| 記録 | |
| コンパイル時間 | 1,891 ms |
| コンパイル使用メモリ | 167,276 KB |
| 実行使用メモリ | 92,392 KB |
| 最終ジャッジ日時 | 2026-02-28 15:15:25 |
| 合計ジャッジ時間 | 4,867 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 7 WA * 3 RE * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int make_and_count(int array[], int n, int d) {
int count = 0;
int table[n][n]={0},table2[n][n]={0};
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
if(array[j] - array[i] == d) {
table[i][j] = table[i][j-1] + 1;
}
}
}
for(int j=n-1;j>=0;j--) {
for(int i=j-1;i>=0;i--) {
if(array[j] - array[i] == d) {
table2[i][j] = table2[i+1][j] + 1;
}
}
}
for(int i=0;i<n;i++) {
for(int j=i+1;j<n;j++) {
count += table[i][j] * table2[i][j];
}
}
return count;
}
int main(){
int n;
int d;
cin >> n >> d;
int array[n];
for(int i=0;i<n;i++) cin >> array[i];
int count = make_and_count(array, n, d);
cout << count << endl;
return 0;
}
U10