/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Wrong Answer 59ms 4.309 MiB
#3 Wrong Answer 56ms 4.297 MiB

Code

#include<bits/stdc++.h>
using namespace std;

#define RASHED ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long int

#define show(x) cout << #x << " = " << x << endl
#define inf (int)1e17
#define maxn 100010

#define F first
#define S second

void solve(int tc) {
    int n;
    cin>>n;
    vector<int> onsite;
    for(int i=1; i<=n; i++) {
        int x;
        cin>>x;
        onsite.push_back(x);
    }
    sort(onsite.rbegin(),onsite.rend());
    int m;
    cin>>m;
    vector<pair<int,int>> replay;
    int res[m+8],N = n+1;
    for(int i=1; i<=m; i++) {
        int x;
        cin>>x;
        replay.push_back({x,-i});
    }
    sort(replay.rbegin(),replay.rend());
    for(int i=0; i<m; i++) {
        int val = replay[i].F,pos = -(replay[i].S);
        int lo = 0,hi = n-1,pp = inf;
        while(lo <= hi) {
            int mid = (lo+hi)/2;
            if(val > onsite[mid]) {
                pp = min(pp,mid+1);
                hi = mid-1;
            } else lo = mid+1;
        }
        ///show(pp);
        if(pp == inf) {
            res[pos] = N;
            N++;
        } else res[pos] = pp+i;
    }
    for(int i=1; i<=m; i++)cout<<res[i]<<" ";
}
signed main() {
    RASHED
    int TC = 1;
    ///cin>>TC;
    for(int i=1; i<=TC; i++)solve(i);
    return 0;
}
/**
CASES:

*/

Information

Submit By
Type
Submission
Problem
P1049 Combined scoreboard
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-07 11:03:17
Judged At
2024-11-11 03:30:56
Judged By
Score
5
Total Time
59ms
Peak Memory
4.309 MiB