/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Wrong Answer 214ms 7.398 MiB
#3 Wrong Answer 214ms 7.242 MiB

Code

#include<bits/stdc++.h>

//#include <Windows.h> Sleep(300);
using namespace std;
//#define int long long
#define endl '\n'
#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mod 1000000007
#define log(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cout<<endl; }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << " ";
	err(++it, args...);
}
#define fr(i, n) for(int i=0; i<n; i++)
#define fr1(i, n) for(int i=1; i<=n; i++)
#define fab(i, a, b) for(int i=a; i<b; i++)
const int dx[]={+1,-1,+0,+0};
const int dy[]={+0,+0,+1,-1};

int32_t main() {
    int t=1; //cin>>t;

    while(t--){
        int n; cin>>n;
        vector<pii> v;
        map<int, vi > firstScore;
        fr(i, n){int x; cin>>x; v.pb({x, i}); firstScore[x].pb(i); }
        int m; cin>>m;
        vi replay(m);
        fr(i, m){int x; cin>>x; v.pb({x, n+i}); replay[i] = x; }
        sort(v.begin(), v.end(), greater<pii>());
        int pos = 0;
        map<int, vi> ans;
        fr(i, m+n) {  //log(v[i].first, v[i].second);
            //if(replay[i]==v[i].first){
                if(firstScore.count(v[i].first)){
                    int sz = firstScore[v[i].first].size();
                    i+=sz; i--;
                    pos+=sz; pos--;
                    firstScore.erase(v[i].first);
                }

                else {
                    //ans[pos++] = i+1;
                    //cout<<i+1<<" "<<v[i].first<<endl;;
                    ans[v[i].first].pb(i + 1);
                }
            //}
        }
        vi ret;
        fr(i, m){
            int r = replay[i];
            for(auto x: ans[r]) ret.pb(x);
            ans.erase(r);
        }

        fr(i, ret.size()){
            cout<<ret[i];
            if(i!=ret.size()-1) cout<<" ";
        }
   }

}

Information

Submit By
Type
Submission
Problem
P1049 Combined scoreboard
Contest
Brain Booster #3
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 16:26:32
Judged At
2024-11-11 03:33:07
Judged By
Score
5
Total Time
214ms
Peak Memory
7.398 MiB