QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#583439#9370. Gambling on Choosing RegionalsLine_MaoTL 0ms3808kbC++981.1kb2024-09-22 19:57:022024-09-22 19:57:02

Judging History

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

  • [2024-09-22 19:57:02]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3808kb
  • [2024-09-22 19:57:02]
  • 提交

answer

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

int main()
{
	int n, k; cin >> n >> k;
	vector<int>c(k);
	for (int i = 0; i < k; i++) {
		cin >> c[i];
	}
	sort(c.begin(),c.end());

	vector<int>a(n);
	vector<string>b(n);
	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: 100
Accepted
time: 0ms
memory: 3596kb

input:

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

output:

2
1
2
2
1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

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

output:

4
2
4
3
1

result:

ok 5 lines

Test #3:

score: -100
Time Limit Exceeded

input:

100000 100000
57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...

output:

1000
999
1000
1000
1000
1000
1000
1000
1000
869
1000
958
1000
1000
1000
1000
999
1000
1000
1000
1000
1000
1000
990
1000
1000
1000
631
1000
1000
1000
956
1000
1000
1000
1000
1000
1000
575
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
993
1000
1000
999
1000
995
1000
1...

result: