QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#628786#9370. Gambling on Choosing RegionalsacdwzTL 2ms8336kbC++14913b2024-10-10 22:16:222024-10-10 22:16:24

Judging History

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

  • [2024-10-10 22:16:24]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:8336kb
  • [2024-10-10 22:16:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long long int c[100005];
long long int w[100005];
string s[100005];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++) cin>>c[i];
	sort(c+1,c+k+1);
	long long int l=c[1];
	map<string,set<long long int>> ma;
	for(int i=1;i<=n;i++){
		cin>>w[i];
		cin>>s[i];
		ma[s[i]].insert(w[i]);
	}
	int q=1;
	while(n--){
		l=c[1];
		long long int e=w[q];
		string te=s[q];
		int rank=1;
		for(auto it=ma.begin();it!=ma.end();it++){
			l=c[1];
			int v=0;
			if(it->first!=te){
				for(auto ct=it->second.rbegin();ct!=it->second.rend();ct++){
					v++;
					if(*ct>e) rank++;
					if(v>=l) break;
				}
			}
			else{
				l--;
				for(auto ct=it->second.rbegin();ct!=it->second.rend();ct++){
					if(*ct==e) continue;
					v++;
					if(v>l) break;
					if(*ct>e) rank++;
				}
			}
		}
		cout<<rank<<'\n';
		q++;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 6924kb

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: