結果
問題 |
No.3016 ハチマキおじさん
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:01:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,207 bytes |
コンパイル時間 | 4,000 ms |
コンパイル使用メモリ | 202,536 KB |
実行使用メモリ | 10,248 KB |
最終ジャッジ日時 | 2025-04-16 16:07:17 |
合計ジャッジ時間 | 7,298 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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; }