結果
| 問題 |
No.3016 ハチマキおじさん
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 22:54:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,207 bytes |
| コンパイル時間 | 2,018 ms |
| コンパイル使用メモリ | 202,708 KB |
| 実行使用メモリ | 9,736 KB |
| 最終ジャッジ日時 | 2025-04-15 22:56:19 |
| 合計ジャッジ時間 | 4,653 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N, M;
cin >> N >> M;
vector<long long> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
sort(A.begin(), A.end());
vector<pair<long long, int>> counts;
if (N == 0) {
counts = {};
} else {
int current_count = 1;
for (int i = 1; i < N; ++i) {
if (A[i] == A[i-1]) {
current_count++;
} else {
counts.emplace_back(A[i-1], current_count);
current_count = 1;
}
}
counts.emplace_back(A.back(), current_count);
}
for (int i = 0; i < M; ++i) {
long long b;
cin >> b;
auto it = lower_bound(counts.begin(), counts.end(), make_pair(b, 0),
[](const pair<long long, int>& x, const pair<long long, int>& y) {
return x.first < y.first;
});
if (it != counts.end() && it->first == b) {
cout << it->second << " ";
} else {
cout << "0 ";
}
}
return 0;
}
lam6er