QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582895#9370. Gambling on Choosing Regionals17yTL 0ms3760kbC++201.0kb2024-09-22 17:44:092024-09-22 17:44:11

Judging History

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

  • [2024-09-22 17:44:11]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3760kb
  • [2024-09-22 17:44:09]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

void sol(){
    ll n,k;cin>>n>>k;
    ll c=2e18;
    for(int i=0;i<k;i++){
        ll x;cin>>x;
        c=min(x,c);
    }
    set<string>st;
    map<string,int>mp;
    vector<pair<string,ll>>s(n);
    int cnt=0;
    vector<ll>a[n+1];
    for(int i=0;i<n;i++){
        cin>>s[i].second>>s[i].first;
        st.emplace(s[i].first);
        if(!mp.count(s[i].first))    mp[s[i].first]=++cnt;
        a[mp[s[i].first]].push_back(s[i].second);
    }
    for(auto it:st){
        sort(a[mp[it]].begin(),a[mp[it]].end());
    }
    for(int i=0;i<n;i++){
        ll ans=0;
        for(auto it:st){
            auto cnt=upper_bound(a[mp[it]].begin(),a[mp[it]].end(),s[i].second)-a[mp[it]].begin();
            ll cnt1=a[mp[it]].size()-cnt;
            if(it==s[i].first)  ans+=min(c-1,cnt1);
            else ans+=min(c,cnt1);
        }
        cout<<ans+1<<'\n';
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    sol();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

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: 3548kb

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...

result: