⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 3582281_ac_63ms_248k.cpp

📁 北大大牛代码 1240道题的原代码 超级权威
💻 CPP
字号:
#include <stdio.h>
#include <algorithm>

using namespace std;

struct SunScreen
{
	int spf;
	int cnt;

	bool operator < (const SunScreen & that)	const
	{
		return spf < that.spf;
	}
};

struct Cow
{
	int min;
	int max;

	bool operator < (const Cow & that)	const
	{
		return max < that.max;
	}
};

SunScreen sun[2500];
Cow cow[2500];

int main()
{
	int c, l, i, j, ans;

	scanf("%d%d", &c, &l);
	for (i = 0; i < c; i++)
	{
		scanf("%d%d", &cow[i].min, &cow[i].max);
	}
	for (i = 0; i < l; i++)
	{
		scanf("%d%d", &sun[i].spf, &sun[i].cnt);
	}
	sort(cow, cow + c);
	sort(sun, sun + l);
	ans = 0;
	for (i = 0; i < c; i++)
	{
		for (j = 0; j < l; j++)
		{
			if (sun[j].cnt != 0 && sun[j].spf <= cow[i].max && sun[j].spf >= cow[i].min)
			{
				ans++;
				sun[j].cnt--;
				break;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -