結果
| 問題 |
No.206 数の積集合を求めるクエリ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-11 21:36:42 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4,997 ms / 7,000 ms |
| コード長 | 677 bytes |
| コンパイル時間 | 1,993 ms |
| コンパイル使用メモリ | 177,136 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-24 13:23:31 |
| 合計ジャッジ時間 | 24,140 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int L, M, N;
cin >> L >> M >> N;
vector<int> a(L), b(M);
for (int i = 0; i < L; i++) cin >> a[i];
for (int i = 0; i < M; i++) cin >> b[i];
int Q;
cin >> Q;
sort(a.begin(), a.end());
sort(b.begin(), b.end());
vector<int> cnt(Q, 0);
deque<int> dq;
for (int i = 0, j = 0; i < L; i++) {
while (j < M) {
if (a[i] < b[j]) break;
dq.push_back(b[j]);
j++;
}
while (!dq.empty()) {
if (dq.front() + Q > a[i]) break;
dq.pop_front();
}
for (int x : dq) cnt[a[i] - x]++;
}
for (int i = 0; i < Q; i++) {
cout << cnt[i] << endl;
}
return 0;
}