/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Wrong Answer 74ms 5.055 MiB
#3 Wrong Answer 77ms 5.043 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]<<" ";
    cout<<res[m];
}
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++17 (G++ 13.2.0)
Submit At
2024-05-07 11:04:35
Judged At
2024-11-11 03:30:55
Judged By
Score
5
Total Time
77ms
Peak Memory
5.055 MiB