QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626082#9370. Gambling on Choosing Regionals2366503423WA 139ms14252kbC++141.2kb2024-10-09 23:03:482024-10-09 23:03:49

Judging History

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

  • [2024-10-09 23:03:49]
  • 评测
  • 测评结果:WA
  • 用时:139ms
  • 内存:14252kb
  • [2024-10-09 23:03:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
bool cmp(long long int a,long long int b)
{
	return a>b;
}
int main()
{
	int n,k;cin>>n>>k;
	set <int> xiao;
	for(int i=0;i<k;i++){long long int x;cin>>x;xiao.insert(x);}
	k=*xiao.begin();//cout<<k<<'\n';
	map < string , vector<long long int> > ma; 
	vector <long long int> dui,pai,pai2; 
	map <long long int,int> book,ans;
	for(int i=0;i<n;i++)
	{
		string s;long long int x;cin>>x>>s;
		ma[s].push_back(x);
		dui.push_back(x);
	}
	for(auto &it:ma)
	{
		sort(it.second.begin(),it.second.end(),cmp);
	}
	for(auto &it:ma)
	{
		for(int i=0;i<it.second.size();i++)
		{
			if(i+1<=k) 
			{
			    pai.push_back(it.second[i]);
			    book[it.second[i]]=1;
		    }
		}
	}
	sort(pai.begin(),pai.end(),cmp);
	for(int i=0;i<pai.size();i++)
	{
		ans[pai[i]]=i+1;
		//cout<<pai[i]<<"**"<<'\n';
	}
	for(int i=pai.size()-1;i>=0;i--)
	{
		pai2.push_back(pai[i]);
	}
	for(int i=0;i<dui.size();i++)
	{
		if(book[dui[i]]==1) cout<<ans[dui[i]];
		else
		{
			int ans=lower_bound(pai2.begin(),pai2.end(),dui[i])-pai2.begin();
			if(ans!=0) cout<<ans;
			else cout<<pai2.size();
		}
		cout<<'\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3760kb

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

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
Wrong Answer
time: 139ms
memory: 14252kb

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
1
1000
1000
1000
1000
1000
1000
1000
131
1000
42
1000
1000
1000
1000
1
1000
1000
1000
1000
1000
1000
10
1000
1000
1000
631
1000
1000
1000
44
1000
1000
1000
1000
1000
1000
575
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
7
1000
1000
1
1000
5
1000
1000
1000
1000...

result:

wrong answer 2nd lines differ - expected: '999', found: '1'