QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#580908 | #9370. Gambling on Choosing Regionals | zhangchao_gjc | TL | 0ms | 3832kb | C++17 | 2.5kb | 2024-09-22 00:53:39 | 2024-09-22 00:53:40 |
Judging History
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;
}
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(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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
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: 3752kb
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...