QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#592259#9370. Gambling on Choosing RegionalsHe2717970784WA 98ms11564kbC++171.5kb2024-09-26 21:36:212024-09-26 21:36:21

Judging History

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

  • [2024-09-26 21:36:21]
  • 评测
  • 测评结果:WA
  • 用时:98ms
  • 内存:11564kb
  • [2024-09-26 21:36:21]
  • 提交

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 l;
}

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

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

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: 98ms
memory: 11564kb

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'