QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#583464 | #9370. Gambling on Choosing Regionals | Line_Mao | TL | 0ms | 3800kb | C++20 | 964b | 2024-09-22 20:02:49 | 2024-09-22 20:02:49 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
int n, k; cin >> n >> k;
vector<int>c(k);
for (int i = 0; i < k; i++) {
cin >> c[i];
}
sort(c.begin(),c.end());
vector<int>a(n);
vector<string>b(n);
map<string, vector<int>>mp;
for (int i = 0; i < n; i++)
{
cin >> a[i] >> b[i];
mp[b[i]].push_back(a[i]);
}
for (auto&mp1:mp)
{
sort(mp1.second.begin(), mp1.second.end());
}
for (int i = 0; i < n; i++)
{
int ans = 1;
for (auto&it:mp)
{
if (it.first == b[i])
{
for (int j = c[0] - 1; j > 0; j--)
{
if (a[i] < it.second[mp[it.first].size() - j])
{
ans = ans + j;
break;
}
}
}
else
{
for (int j = c[0]; j > 0; j--)
{
if (a[i] < it.second[mp[it.first].size() - j])
{
ans += j;
break;
}
}
}
}
cout << ans << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
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: 3792kb
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...