結果
| 問題 | No.647 明太子 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-09 17:04:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 4,500 ms |
| コード長 | 1,067 bytes |
| コンパイル時間 | 2,339 ms |
| コンパイル使用メモリ | 76,384 KB |
| 最終ジャッジ日時 | 2025-01-09 15:30:22 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
void solve() {
int n;
std::cin >> n;
std::vector<std::pair<int, int>> ps(n);
for (auto& p : ps) std::cin >> p.first >> p.second;
int m;
std::cin >> m;
std::vector<std::pair<int, int>> qs(m);
for (auto& q : qs) std::cin >> q.first >> q.second;
std::vector<int> cnt(m, 0);
for (auto p : ps) {
for (int i = 0; i < m; ++i) {
auto q = qs[i];
if (q.first <= p.first &&
p.second <= q.second) {
++cnt[i];
}
}
}
std::vector<int> ans;
int max = 0;
for (int i = 0; i < m; ++i) {
if (cnt[i] > max) {
max = cnt[i];
ans.clear();
}
if (cnt[i] == max) {
ans.push_back(i + 1);
}
}
if (max == 0) {
std::cout << 0 << std::endl;
} else {
for (auto a : ans) std::cout << a << std::endl;
}
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}