Submission #73916855


Source Code Expand

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll=long long;
using ull= unsigned long long;
const int inf=INT_MIN/2;
const ll mod=998244353;
void s()
{
    int n,q;
    cin >>n>>q;
    vector<pair<int,int>> a(n+1);
    priority_queue<pair<int,int>, vector<pair<int,int>>,greater<pair<int,int>>> pq; 
    for(int i=1;i<=n;i++) {
        auto &[x,y]=a[i];
        cin >>x;
        y=i;
        pq.push({x,y});
    }
    while(q--) {
        int k;
        cin >>k;
        vector<int> ak(k);
        vector<pair<int,int>> old;
        for(auto & x : ak) cin >>x;
         while(1) {
            auto [v,p]=pq.top();
            int flag=0;
            for( int i=0;i<k;i++) {
                if(p==ak[i]) {
                    flag=1;
                    break;
                }
            }
            if(flag) {
                old.push_back(pq.top());
                pq.pop();
            }
            else {
                cout <<v<<endl;
                for(auto & x : old) pq.push(x);
                break;
            }
         }
    }
}
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    // int n;
    // cin >>n;
    // for(int i=0;i<n;i++)
    s();

}

Submission Info

Submission Time
Task C - Except and Min
User Li_x
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1272 Byte
Status AC
Exec Time 56 ms
Memory 10020 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 19
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 02_random_2_00.txt, 02_random_2_01.txt, 02_random_2_02.txt, 02_random_2_03.txt, 02_random_2_04.txt, 02_random_2_05.txt, 03_random_3_00.txt, 03_random_3_01.txt, 03_random_3_02.txt, 03_random_3_03.txt, 03_random_3_04.txt, 03_random_3_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3624 KiB
01_random_00.txt AC 40 ms 9820 KiB
01_random_01.txt AC 35 ms 9820 KiB
01_random_02.txt AC 39 ms 9952 KiB
01_random_03.txt AC 40 ms 9940 KiB
01_random_04.txt AC 37 ms 10020 KiB
01_random_05.txt AC 37 ms 9896 KiB
02_random_2_00.txt AC 48 ms 9964 KiB
02_random_2_01.txt AC 46 ms 9808 KiB
02_random_2_02.txt AC 44 ms 9820 KiB
02_random_2_03.txt AC 48 ms 9804 KiB
02_random_2_04.txt AC 43 ms 9880 KiB
02_random_2_05.txt AC 43 ms 9884 KiB
03_random_3_00.txt AC 55 ms 9852 KiB
03_random_3_01.txt AC 54 ms 9888 KiB
03_random_3_02.txt AC 55 ms 9948 KiB
03_random_3_03.txt AC 55 ms 9840 KiB
03_random_3_04.txt AC 56 ms 9820 KiB
03_random_3_05.txt AC 55 ms 9960 KiB