結果

問題 No.647 明太子
コンテスト
ユーザー AQUA16573837
提出日時 2018-04-03 19:48:38
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 28 ms / 4,500 ms
コード長 858 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 573 ms
コンパイル使用メモリ 62,716 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2026-03-14 06:04:14
合計ジャッジ時間 1,679 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <algorithm>
#include <deque>
using namespace std;
using ll = long long;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif
}

//647
void solve() {
	int n, a[10000], b[10000], m, c[1001], x, y;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d", a + i, b + i);
	scanf("%d", &m);
	c[0] = 0;
	for (int i = 1; i <= m; i++) {
		c[i] = 0;
		scanf("%d %d", &x, &y);
		for (int j = 0; j < n; j++)
			if (x <= a[j] && b[j] <= y)
				c[i]++;
	}
	int idx[1001];
	for (int i = 0; i <= 1000; i++)
		idx[i] = i;
	sort(idx, idx + m + 1, [&](int a, int b) {
		if (c[a] != c[b])
			return c[a] > c[b];
		return a < b;
	});

	if (idx[0] == 0) {
		printf("0\n");
	}
	else {
		printf("%d\n", idx[0]);
		for (int i = 1; i < m + 1; i++) {
			if (c[idx[i]] != c[idx[i - 1]])
				break;
			printf("%d\n", idx[i]);
		}
	}
}
0