QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#723730#6693. Fast and FatvwxyzWA 686ms10704kbPython3798b2024-11-07 23:55:482024-11-07 23:55:52

Judging History

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

  • [2024-11-07 23:55:52]
  • 评测
  • 测评结果:WA
  • 用时:686ms
  • 内存:10704kb
  • [2024-11-07 23:55:48]
  • 提交

answer

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok

T=int(input())
for t in range(T):
    N=int(input())
    V,W=[],[]
    for i in range(N):
        v,w=map(int,input().split())
        V.append(v)
        W.append(w)
    def is_ok(ans):
        A,B=[],[]
        for v,w in zip(V,W):
            if ans<v:
                A.append(v+w-ans)
            elif v<ans:
                B.append(w)
        A.sort(reverse=True)
        B.sort(reverse=True)
        if len(A)<len(B):
            return False
        for a,b in zip(A,B):
            if a<b:
                return False
        return True
    ans=Bisect_Int(0,1<<40,is_ok)
    print(ans)

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 10704kb

input:

2
5
10 5
1 102
10 100
7 4
9 50
2
1 100
10 1

output:

8
1

result:

ok 2 number(s): "8 1"

Test #2:

score: -100
Wrong Answer
time: 686ms
memory: 10584kb

input:

10000
4
280251502 664541723
375808746 641141991
95134537 898607509
455259328 944978891
2
798417052 547329847
785434740 991778535
6
623628702 857611223
275667427 453747403
292209526 283132767
330752033 988721243
470297536 608192332
477186035 325224271
3
280572174 994054447
306566740 923535026
3781360...

output:

352409014
785434740
470297535
280572173
704877362
960871618
691253608
560579094
136979645
399988835
610497257
576427564
636500913
315900405
370430730
526259135
781258283
631916851
300930080
419999539
431930706
479323438
530080164
391912906
708925498
467782812
457987604
389750718
447390353
696516804
...

result:

wrong answer 3rd numbers differ - expected: '470297536', found: '470297535'