QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580993 | #9370. Gambling on Choosing Regionals | zhangchao_gjc | RE | 0ms | 0kb | C++17 | 2.5kb | 2024-09-22 02:40:07 | 2024-09-22 02:40:07 |
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);
}
unordered_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;
}
vector<vector<int>>sb(mp.size());
int j = 0;
for (auto it : mp)
{
sort(it.second.begin(), it.second.end());
sb[j++] = it.second;
//vdb(it.second);
}
//cout << endl;
/*for (auto it : mp)
{
vdb(it.second);
}*/
/*for (int i = 0; i < mp.size(); i++)
{
for (int j = 0; j < sb[i].size(); j++)
{
cout << sb[i][j] << " ";
}
cout << endl;
}*/
//debug
//cout << endl;
for (int i = 0; i < n; i++)
{
//cout << b[i] << " ";
int res = 0;
int k = 0;
for (auto it : mp)
{
//vector<int>c = sb[k];
k++;
//sort(c.begin(), c.end());
//vdb(c);
//cout << b[i] << endl;
int id = upper_bound(sb[k].begin(), sb[k].end(), b[i]) - sb[k].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;
}
详细
Test #1:
score: 0
Runtime Error
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU