結果
| 問題 |
No.647 明太子
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-09 23:41:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,641 ms / 4,500 ms |
| コード長 | 2,310 bytes |
| コンパイル時間 | 1,169 ms |
| コンパイル使用メモリ | 99,500 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-27 02:36:32 |
| 合計ジャッジ時間 | 6,451 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
43 | scanf("%d%d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:46:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
46 | scanf("%d", &m);
| ~~~~~^~~~~~~~~~
main.cpp:49:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d%d", &a, &b);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
using namespace std;
#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x) { cout << #x << ": "; \
for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif
typedef pair<int, int> p;
int n, m;
vector<p> member;
vector<p> mentai_a;
vector<p> mentai_b;
vector<int> vote;
int main(int argc, char *argv[]) {
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int a, b;
scanf("%d%d", &a, &b);
member.push_back(p(a, b));
}
scanf("%d", &m);
for (int i = 0; i < m; ++i) {
int a, b;
scanf("%d%d", &a, &b);
mentai_a.push_back(p(a, i));
mentai_b.push_back(p(b, i));
}
sort(mentai_a.begin(), mentai_a.end());
sort(mentai_b.begin(), mentai_b.end());
vote.resize(m);
memset(&vote[0], 0, sizeof(int) * m);
set<int> fav_a;
set<int> fav_b;
vector<int> fav;
for (int i = 0; i < n; ++i) {
auto it_a = upper_bound(mentai_a.begin(), mentai_a.end(), p(member[i].first+1, 0));
fav_a.clear();
for (auto it = mentai_a.begin(); it != it_a; ++it) {
fav_a.insert(it->second);
}
fav_b.clear();
auto it_b = lower_bound(mentai_b.begin(), mentai_b.end(), p(member[i].second, 0));
for (auto it = it_b; it != mentai_b.end(); ++it) {
fav_b.insert(it->second);
}
fav.clear();
set_intersection(fav_a.begin(), fav_a.end(),
fav_b.begin(), fav_b.end(),
back_inserter(fav));
for (int v : fav) {
++vote[v];
}
}
int vmax = 0;
for (int i = 0; i < m; ++i) {
if (vmax < vote[i]) vmax = vote[i];
}
if (vmax == 0)
{
puts("0");
return 0;
}
for (int i = 0; i < m; ++i) {
if (vote[i] == vmax)
printf("%d\n", i+ 1);
}
return 0;
}