結果
問題 |
No.1110 好きな歌
|
ユーザー |
![]() |
提出日時 | 2020-07-20 09:22:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 351 ms / 5,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 1,608 ms |
コンパイル使用メモリ | 174,544 KB |
実行使用メモリ | 5,712 KB |
最終ジャッジ日時 | 2024-12-23 03:24:48 |
合計ジャッジ時間 | 13,524 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 51 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, d; cin >> n >> d; vector<pair<int, int>> v; for (int i = 0; i < n; i++) { int a; cin >> a; v.push_back(make_pair(a, i)); } sort(v.begin(), v.end()); vector<int> answer(n, 0); int count = 0; int num = 0; for (int i = 0; i < n; i++) { while (v.at(i).first - d >= v.at(num).first) { count++; num++; } if (v.at(i).first - d < v.at(num).first) { answer.at(v.at(i).second) = count; } } for (int x : answer) { cout << x << endl; } }