QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#121432#5642. DA-Sortkaitlinz100 ✓5ms8188kbPython3755b2023-07-08 06:11:412023-07-08 06:11:45

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-08 06:11:45]
  • 评测
  • 测评结果:100
  • 用时:5ms
  • 内存:8188kb
  • [2023-07-08 06:11:41]
  • 提交

answer


# Online Python - IDE, Editor, Compiler, Interpreter

def ceiling_division(n, d):
    q, r = divmod(n, d)
    return q + bool(r)
    
def solve(arr):
    newArr = sorted(arr[:])
    idx, newidx = 0,0
    
    while idx < len(arr) and newidx < len(newArr):
        if arr[idx] == newArr[newidx]:
            idx+=1 
            newidx+=1 
        else: # arr[idx] < newArr[newidx]:
            idx += 1
    return len(newArr) - newidx
            
        
        
        
setNum = int(input())
for i in range(setNum):
    probNum, elems = [int(x) for x in input().split()]
    arr = []
    for j in range(ceiling_division(elems, 10)):
        arr += [int(x) for x in input().split()]
    print(probNum, solve(arr))

    

詳細信息

Test #1:

score: 100
Accepted
time: 5ms
memory: 8188kb

input:

50
1 3
1 3 2
2 6
1 5 2 4 3 6
3 23
67890 56312 999999999 12345 23456 38927 45632 100345 98765 23456
87654 43278 23456 117654 321899 25432 54326 217435 26845 31782
33456 41234 56213
4 1000
18780 15256 15263 15268 15269 15274 15279 15279 15283 15290
15292 15292 15295 15298 15302 15305 15305 15311 15316...

output:

1 1
2 3
3 15
4 1
5 0
6 0
7 0
8 0
9 999
10 1
11 500
12 2
13 299
14 159
15 36
16 564
17 94
18 0
19 140
20 438
21 182
22 364
23 364
24 45
25 147
26 16
27 66
28 85
29 406
30 325
31 564
32 268
33 9
34 248
35 524
36 335
37 498
38 43
39 392
40 589
41 157
42 148
43 41
44 576
45 177
46 332
47 187
48 22
49 99...

result:

ok 50 lines