QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587261#9370. Gambling on Choosing RegionalsSocialPandaTL 0ms3624kbC++231.1kb2024-09-24 18:56:462024-09-24 18:56:46

Judging History

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

  • [2024-09-24 18:56:46]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3624kb
  • [2024-09-24 18:56:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define se second
#define fi first
#define pb push_back
#define eb emplace_back

map<string,vector<int>> sc;

void solve()
{
	int n,k;
	cin>>n>>k;
	int c[k+1];
		//cout<<team<<'!'<<endl;

	for(int i=1;i<=k;i++) cin>>c[i];
	vector<pair<int,string>> vec;

	for(int i=1;i<=n;i++)
	{
		int num;
		string team;
		cin>>num>>team;
		sc[team].pb(num);
		vec.pb({num,team});
	}
	for(auto &z:sc)
	{
		sort(z.se.begin(),z.se.end());
	}

	for(auto tm:vec)
	{
		int num = tm.fi;
		string team = tm.se;


		int ans=1e14;
		for(int i=1;i<=k;i++)
		{
			int rk=1;
			int max_c = c[i];
			for(auto z:sc)
			{
				int js=0;
				if(z.fi==team) js=1;
				auto vx = z.se;
				int t = lower_bound(vx.begin(), vx.end(), num) - vx.begin();

				t = vx.size()-t;

				rk += min(t,max_c);	
				if(js) rk--;
			}


			ans=min(ans,rk);
		}

		cout<<ans<<endl;
	}

}
/*

2 4 8 16 32 64
31 -> 36

*/
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tt=1;
	//cin>>tt;
	while(tt--) solve();
}

详细

Test #1:

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

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

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: