QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#592279 | #9370. Gambling on Choosing Regionals | He2717970784 | WA | 116ms | 11708kb | C++17 | 1.5kb | 2024-09-26 21:44:15 | 2024-09-26 21:44:18 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 2e18;
int get(vector<int>&v,int x){
int n = v.size();
int l = 0,r = n;
while((l <= r) && (l < n)){
int mid = (l + r) >> 1;
if(v[mid] >= x){
l = mid + 1;
}
else{
r = mid - 1;
}
}
return min(l,n);
}
void solve(){
int n = 0,k = 0;
cin >> n >> k;
int mn = INF;
for(int i = 0;i < k;i++){
int x = 0;
cin >> x;
mn = min(mn,x);
}
map<string,vector<int>>v;
map<int,int>mp;
for(int i = 0;i < n;i++){
int val = 0;
string s;
cin >> val >> s;
v[s].push_back(val);
mp[val] = i;
}
vector<int>vec;
for(auto& it : v){
sort(it.second.begin(),it.second.end(),greater<int>());
}
for(auto& it : v){
for(int i = 0;i < min((int)it.second.size(),mn);i++){
vec.push_back(it.second[i]);
}
}
vector<int>ans(n);
for(auto& it : v){
for(int i = 0;i < (int)it.second.size();i++){
if(i < mn){
ans[mp[it.second[i]]] = get(vec,it.second[i]);
}
else{
ans[mp[it.second[i]]] = get(vec,it.second[i]);
}
}
}
for(int i = 0;i < n;i++){
cout << ans[i] << endl;
}
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
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: 3868kb
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
Wrong Answer
time: 116ms
memory: 11708kb
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 1000 1000 1000 1000 1000 1000 1000 1000 967 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 796 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 796 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
result:
wrong answer 2nd lines differ - expected: '999', found: '1000'