QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587277#9370. Gambling on Choosing RegionalsSocialPandaTL 0ms3612kbC++231.1kb2024-09-24 19:01:592024-09-24 19:02:00

Judging History

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

  • [2024-09-24 19:02:00]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-24 19:01:59]
  • 提交

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<=1;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: 3492kb

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

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:

94907
15938
51981
98470
83677
32345
52328
31696
44705
3240
40243
6189
77801
72454
67601
44666
14040
74317
35039
65000
35508
19143
56593
9110
54778
64546
18367
1344
25930
75155
39938
5884
87260
86787
23307
65666
19346
38658
1131
26532
93599
99215
23152
92308
46948
75923
66463
91436
44056
54275
24935
...

result: