Submission #73914033


Source Code Expand

import sys
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush, heapify
from itertools import product, combinations, accumulate, permutations, groupby
from math import sqrt, isqrt, comb, gcd

input = sys.stdin.readline
sys.setrecursionlimit(10**7)

DIR4 = [(1,0),(-1,0),(0,1),(0,-1)]
DIR8 = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)]

INF = 10**18
YES,NO = "Yes", "No"
MOD = 10**9 + 7
MOD2  = 998244353

def ni(): return int(input())
def nm(): return map(int,input().split())
def nl(): return list(nm())

def si(): return input().strip()
def sm(): return si().split()
def sl(): return list(si())


def main():
    n,q = nm()
    a = nl()
    cnt = Counter(a)
    ans = min(a)
    aaa = ans
    aa = sorted(a)
    for _ in range(q):
        k = ni()
        b = nl()
        dels = []
        for i in b:
            i -= 1
            cnt[a[i]] -= 1
            if cnt[a[i]] == 0:
                dels.append(a[i])
        # print(cnt)
        for i in b:
            i -= 1
            cnt[a[i]] += 1
        # ansが消えたら、cnt[a[i]]ぶん進めた場所が答え
        dels.sort()
        i = 0
        j = 0
        while j < len(dels) and ans == dels[j]:
            i += cnt[dels[j]]
            ans = aa[i]
            j += 1
        print(ans)
        ans = aaa


if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task C - Except and Min
User toppoun
Language Python (PyPy 3.11-v7.3.20)
Score 300
Code Size 1428 Byte
Status AC
Exec Time 559 ms
Memory 219168 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 73 ms 96456 KiB
01_random_00.txt AC 533 ms 218124 KiB
01_random_01.txt AC 321 ms 162592 KiB
01_random_02.txt AC 559 ms 217228 KiB
01_random_03.txt AC 540 ms 218600 KiB
01_random_04.txt AC 424 ms 178460 KiB
01_random_05.txt AC 394 ms 171424 KiB
02_random_2_00.txt AC 533 ms 218512 KiB
02_random_2_01.txt AC 524 ms 211928 KiB
02_random_2_02.txt AC 347 ms 168544 KiB
02_random_2_03.txt AC 527 ms 218120 KiB
02_random_2_04.txt AC 334 ms 167748 KiB
02_random_2_05.txt AC 341 ms 168132 KiB
03_random_3_00.txt AC 500 ms 219168 KiB
03_random_3_01.txt AC 486 ms 219116 KiB
03_random_3_02.txt AC 486 ms 218532 KiB
03_random_3_03.txt AC 487 ms 217680 KiB
03_random_3_04.txt AC 500 ms 218344 KiB
03_random_3_05.txt AC 495 ms 218588 KiB