QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581721#9370. Gambling on Choosing RegionalsLine_MaoML 0ms0kbC++141.1kb2024-09-22 13:59:412024-09-22 13:59:41

Judging History

你现在查看的是最新测评结果

  • [2024-09-22 13:59:41]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2024-09-22 13:59:41]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
	int n, k; cin >> n >> k;

	int c[1000000009];
	for (int i = 0; i < k; i++) {
		cin >> c[i];
	}
	sort(c, c + k);

	int a[100001];
	string b[100001];
	map<string, vector<int>>mp;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
		mp[b[i]].push_back(a[i]);
	}

	for (map<string, vector<int>>::iterator it = mp.begin(); it != mp.end(); it++)
	{
		sort(it->second.begin(), it->second.end());
	}

	for (int i = 0; i < n; i++)
	{
		int ans = 1;
		for (map<string, vector<int>>::iterator it = mp.begin(); it != mp.end(); it++)
		{
			if (it->first == b[i])
			{
				for (int j = c[0] - 1; j > 0; j--)
				{
					if (a[i] < it->second[mp[it->first].size() - j])
					{
						ans = ans + j;
						break;
					}
				}
			}
			else
			{
				for (int j = c[0]; j > 0; j--)
				{
					if (a[i] < it->second[mp[it->first].size() - j])
					{
						ans += j;
						break;
					}
				}
			}
		}
		cout << ans << endl;
	}
}

详细

Test #1:

score: 0
Memory Limit Exceeded

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:


result: