QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#580882#9370. Gambling on Choosing Regionalszhangchao_gjcTL 0ms3632kbC++172.2kb2024-09-22 00:35:462024-09-22 00:35:52

Judging History

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

  • [2024-09-22 00:35:52]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3632kb
  • [2024-09-22 00:35:46]
  • 提交

answer

//C:\Users\Lenovo\AppData\Roaming\Sublime Text\Packages\User
#include<bits/stdc++.h>
#define vdb(a)                                                                                                         \
    cout << (#a) << ':';                                                                                               \
    for (auto _ : a)                                                                                                   \
        cout << ' ' << _;                                                                                              \
    cout << endl
#define int long long
#define ll long long
#define iint __int128
#define endl '\n'
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int, int>
#define debug cout << "ans ";
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define all(a) a.begin(), a.end()
#define st first
#define nd second
using namespace std;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
constexpr int L = 232792560;
const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

void solve()
{
	int n, k;
	cin >> n >> k;
	int mn = 1e9;
	for (int i = 1; i <= k; i++) {
		int x; cin >> x;
		mn = min(mn, x);
	}
	map<string, vector<int>>mp;
	vector<int>b(n);
	vector<string>ss(n);
	for (int i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		string s;
		cin >> s;
		mp[s].push_back(x);
		b[i] = x;
		ss[i] = s;
	}
	for (auto it : mp)
	{
		sort(it.second.begin(), it.second.end());
		//vdb(it.second);
	}
	//debug
		//cout << endl;
	for (int i = 0; i < n; i++)
	{
		//cout << b[i] << " ";
		int res = 0;
		for (auto it : mp)
		{
			vector<int>c = it.second;
			sort(c.begin(), c.end());
			//vdb(c);
			//cout << b[i] << endl;
			int id = upper_bound(c.begin(), c.end(), b[i]) - c.begin();
			id = it.second.size() - id;
			//cout << id << endl;
			if (ss[i] == it.first)
			{
				//cout << "aa";
				id = min(id, mn - 1);
			}
			else
			{
				id = min(id, mn);
			}
			res += id;
			//cout << id << " ";
		}
		cout << res + 1 << endl;
	}
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: