QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#584342#9370. Gambling on Choosing RegionalsSGColinWA 290ms17748kbPython3624b2024-09-23 12:51:282024-09-23 12:51:29

Judging History

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

  • [2024-09-23 12:51:29]
  • 评测
  • 测评结果:WA
  • 用时:290ms
  • 内存:17748kb
  • [2024-09-23 12:51:28]
  • 提交

answer

from bisect import bisect
d={}
a,_ =map(int,input().split())
n=min(map(int,input().split()))
an=[]
def che(c,x):
    l = 0
    r = len(c) - 1
    # print(x)
    while l < r:
        mid = (l + r) // 2
        if c[mid] >= x :
            r = mid
        else :
            l = mid + 1

    return l


for _ in range(a):
    a1,a2=input().split()
    a1=int(a1)
    an.append(a1)
    if a2 in d:
        d[a2].append(a1)
    else:d[a2]=[a1]
c=[]
for i in d.values():
    i.sort()
    c+=i[len(i)-n:]
c.sort()
# c=c[::-1]
# print(c)
m = len(c)
for i in an:
    k=  m - che(c,i)
    print(k)

详细

Test #1:

score: 100
Accepted
time: 10ms
memory: 10756kb

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

2
1
2
2
1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 10ms
memory: 10576kb

input:

5 2
2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:

4
2
4
3
1

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 207ms
memory: 17748kb

input:

100000 100000
57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...

output:

1000
999
1000
1000
1000
1000
1000
1000
1000
869
1000
958
1000
1000
1000
1000
999
1000
1000
1000
1000
1000
1000
990
1000
1000
1000
631
1000
1000
1000
956
1000
1000
1000
1000
1000
1000
575
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
993
1000
1000
999
1000
995
1000
1...

result:

ok 100000 lines

Test #4:

score: -100
Wrong Answer
time: 290ms
memory: 17208kb

input:

100000 100000
67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...

output:

35629
62683
8008
65220
13918
6830
44588
50293
23656
21711
63616
57843
39937
32831
34742
65288
20781
53194
66520
62343
23221
34906
43769
17487
32670
52098
58465
65743
64747
13017
43892
44436
21654
66008
51278
48788
60305
5075
25964
64892
14708
56112
66370
46351
36876
62299
66205
19284
18848
66069
324...

result:

wrong answer 1st lines differ - expected: '38094', found: '35629'