QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#581274#9370. Gambling on Choosing Regionalsremake1958RE 1ms3836kbC++141.3kb2024-09-22 11:26:222024-09-22 11:26:22

Judging History

你现在查看的是最新测评结果

  • [2024-09-22 11:26:22]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3836kb
  • [2024-09-22 11:26:22]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include<queue>
#include<map>
#include<set>
#define int long long
using namespace std;
const int N=5e3+10;
const int M=1e4+10;



struct node
{
    int srank;
    string name;
    int pos;
}a[N];

int c[N];
map<string,int>ma;

int d[N];//用于记录每个队伍最终可以达到的最好情况下的最差成绩

bool cmp(node a1,node a2)
{
    return a1.srank>a2.srank;
}

void solve()
{
    int n,k;cin>>n>>k;
    ma.clear();
    for(int i=1;i<=k;i++) cin>>c[i];

    sort(c+1,c+1+k);
    for(int i=1;i<=n;i++){
        cin>>a[i].srank>>a[i].name;
        a[i].pos=i;
    }

    sort(a+1,a+1+n,cmp);
    memset(d,0x3f,sizeof(d));
    int m=0;
    for(int i=1;i<=n;i++){
        if(ma[a[i].name]<c[1]){
            d[a[i].pos]=min(i-m,d[a[i].pos]);
            ma[a[i].name]++;
        }
        else{
            m++;
            d[a[i].pos]=min(i-m,d[a[i].pos]);
            ma[a[i].name]++;
        }
    }
    for(int i=1;i<=n;i++){
        cout<<d[i]<<endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    /*int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }*/

    solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3836kb

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: 1ms
memory: 3836kb

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
Runtime Error

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:


result: