QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#585182#9370. Gambling on Choosing RegionalschenncTL 2ms8564kbC++14753b2024-09-23 19:35:082024-09-23 19:35:08

Judging History

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

  • [2024-09-23 19:35:08]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:8564kb
  • [2024-09-23 19:35:08]
  • 提交

answer

#include<bits/stdc++.h> 
using namespace std;
struct g{
	int num;
	string str;
	int score;
};
bool cmp(g i,g j){
	return i.score>j.score;
}
g a[100010];
int ans[100010];
map<string,int>my;
int main(){
	int n,k;
	cin>>n>>k;
	int c;
	int minc=0x3f3f3f3f;
	while(k--){
		cin>>c;
		minc=min(minc,c);
	}
	for(int i=1;i<=n;i++){
		cin>>a[i].score>>a[i].str;
		a[i].num=i;
	}
	sort(a+1,a+n+1,cmp);
	
	for(int i=1;i<=n;i++){
		int rank=1;
		my[a[i].str]=1;
		for(int j=1;j<i;j++){
			if(!my.count(a[j].str)){
				my[a[j].str]=1;
				rank++;
			}
			else if(my[a[j].str]<minc){
				my[a[j].str]++;
				rank++;
			}
		}
		ans[a[i].num]=rank;
		my.clear();
	}
	for(int i=1;i<=n;i++){
		cout << ans[i] << endl; 
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 8440kb

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: 1ms
memory: 8564kb

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: