QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579894#9370. Gambling on Choosing Regionals01h134TL 2ms8492kbC++141.1kb2024-09-21 19:02:282024-09-21 19:02:29

Judging History

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

  • [2024-09-21 19:02:29]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:8492kb
  • [2024-09-21 19:02:28]
  • 提交

answer

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<unordered_map>
#include<vector>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const int inf = 1e9 + 5;

int n, k, mi = inf, ans[N];
struct node {
	ll st, p;
	string s;
	bool operator<(node b) {
		return st > b.st;
	}
}e[N];
unordered_map<string, vector<ll>>ma;
unordered_map<string, int>slip;

signed main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= k; ++i) {
		int x; scanf("%d", &x);
		mi = min(mi, x);
	}
	for (int i = 1; i <= n; ++i)
		cin >> e[i].st >> e[i].s, e[i].p = i;

	sort(e + 1, e + 1 + n);
	for (int i = 1; i <= n; ++i)
		ma[e[i].s].push_back(e[i].st);

	for (int i = 1; i <= n; ++i) {
		int rank = 1;
		for (auto it : ma) {
			int tmp = mi;
			string name = it.first;
			int& p = slip[name];
			if (e[i].s == name)tmp--;
			while (p < it.second.size() && it.second[p] > e[i].st)p++;
			if (p >= tmp)rank += tmp;
			else rank += p;
		}
		ans[e[i].p] = rank;
	}
	for (int i = 1; i <= n; ++i)printf("%d\n", ans[i]);
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 8492kb

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: 2ms
memory: 8472kb

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:


result: