/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 328.0 KiB
#2 Accepted 99ms 540.0 KiB
#3 Accepted 93ms 892.0 KiB
#4 Accepted 90ms 900.0 KiB
#5 Accepted 106ms 1.992 MiB
#6 Accepted 128ms 1.883 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
void solve()
{
     int n , a , q , val; cin >> n ;
     priority_queue < pair < int , int > , vector < pair < int , int> > , greater < pair < int , int > > > pq ;
     for(int i = 1 ; i <= n ; i++){
        cin >> a ;
        pq.push({a , i}) ;
     }
     cin >> q ;
     while(q--){
        cin >> val ;
        auto Ans = pq.top() ;
        cout <<  Ans.S << endl ;
        pq.pop() ;
        pq.push({val , Ans.S}) ;
     }
}
int main()
{
     __Heart__
    // READ("input.txt") ;
    // WRITE("output.txt") ;
     int t ; t = 1 ; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1086 KuZ the Position
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-09 22:49:31
Judged At
2024-08-09 22:49:31
Judged By
Score
100
Total Time
128ms
Peak Memory
1.992 MiB