QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#589782#9370. Gambling on Choosing Regionals2023_ljdRE 0ms0kbC++231.6kb2024-09-25 20:06:092024-09-25 20:06:10

Judging History

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

  • [2024-09-25 20:06:10]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-09-25 20:06:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std ;
#define int long long
const int N = 2e5+10 ;
int ans[N] , str[N] ;
map<string,set<pair<int,int>,greater<pair<int,int>>>> teams ;
vector<pair<int,int>>now ;

bool cmp(pair<int,int> a , pair<int,int> b) {
    return a.first > b.first ;
}

void solve() {
    int n , k , limit=INT_MAX; cin >> n >> k ; 
    for(int i=1 ; i<=k ; i++) {
        int x ; cin >> x ;
        limit = min(limit , x) ;
    }
    for(int i=1 ; i<=n ; i++) {
        int strength ; string sch ;
        cin >> strength >> sch ;
        str[i] = strength ;
        teams[sch].insert({strength , i}) ;
    }
    for(int i=1 ; i<=limit ; i++) {
        while(!teams.empty() && !teams.begin()->second.size())  teams.erase(teams.begin()) ;
        map<string,set<pair<int,int>,greater<pair<int,int>>>>::iterator it = teams.begin() ;
        for( ; next(it)!=teams.end() ; it++) {
            while(!next(it)->second.size())
                teams.erase(next(it)) ;    
        }
        for(auto &x : teams) {
            now.push_back(*x.second.begin()) ;
            x.second.erase(x.second.begin()) ;
        }
    }
    sort(now.begin() , now.end() , cmp) ;
    for(int i=1 ; i<=n ; i++) {
        int rank = upper_bound(now.begin() , now.end() , make_pair(str[i],i) , cmp) - now.begin() ;
        cout << rank << endl ;
    }
    return ;
}

signed main() {
    ios::sync_with_stdio(false) ;
    cin.tie(nullptr) , cout.tie(nullptr) ;
    int t=1 ;   //cin >> t ;
    while(t--)  solve() ;
    system("pause") ;
    return 0 ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Dangerous Syscalls

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

2
1
2
2
1

result: