답안 #636466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636466 2022-08-29T10:31:12 Z beaconmc Sure Bet (CEOI17_sure) C++14
컴파일 오류
0 ms 0 KB
n = int(input())

first = []
second = []

for i in range(n):
    a,b = map(float, input().split())
    a*=10000
    b*=10000
    a = round(a)
    b = round(b)
    first.append(a)
    second.append(b)
first.sort(reverse=True)
second.sort(reverse=True)

def test(x):
    sus1 = first[0]
    sus2 = second[0]
    
    count = 2
    f = 1
    s = 1
    while not (f==n and s==n):
        if f!=n and sus1-count*10000 < x:
            sus1 += first[f]
            f+=1
            count += 1
            continue

        if s!=n and sus2-count*10000 < x:
            sus2 += second[s]
            s+=1
            count += 1
            continue
        break
    if min(sus1-count*10000, sus2-count*10000) <x:
        return False
    else:
        return True

lo = 0
hi = 10000000000000

while (lo<hi):
    mid = (lo+hi+1)//2
    if test(mid):
        lo = mid
    else:
        hi = mid-1
print("%.4lf"%(lo/10000))
        

Compilation message

sure.cpp:1:1: error: 'n' does not name a type
    1 | n = int(input())
      | ^