QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586035 | #9370. Gambling on Choosing Regionals | Abcl | WA | 12ms | 58300kb | C++14 | 1.0kb | 2024-09-24 00:12:21 | 2024-09-24 00:12:21 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
const int N=1000005;
int n,k;
map<string,int> mp;//学校去的队伍数
struct node{
int w,id,rank;
string s;
}a[N];
bool cmp(node x,node y){
return x.w>y.w;
}
bool cmp1(node x,node y){
return x.id<y.id;
}
void solve(){
cin>>n>>k;
int minl=1e15;
for(int i=1,x;i<=k;i++){
cin>>x;minl=min(minl,x);
}
for(int i=1;i<=n;i++){
cin>>a[i].w>>a[i].s;
a[i].id=i;
}
sort(a+1,a+1+n,cmp);
int d=0;
//把所有队伍全部塞进这个赛区
for(int i=1;i<=n;i++){
a[i].rank=i-d;//计算排名
if(mp[a[i].s]>=minl){
a[i].rank--;//本校名额超了就让前边出队一个
mp[a[i].s]++;
d++;
}
}
sort(a+1,a+1+n,cmp1);
for(int i=1;i<=n;i++){
cout<<a[i].rank<<endl;
}
return;
}
signed main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T_case=1;
//cin>>T_case;
while(T_case--){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 58300kb
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU
output:
4 2 5 3 1
result:
wrong answer 1st lines differ - expected: '2', found: '4'