Submission #928483


Source Code Expand

Copy
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N = n()

z, x = ln()

for i in xrange(N - 1):
    t, a = ln()
    q = t + a
    r1 = (z + x) / q
    if (z + x) % q != 0:
        r1 += 1
    r2 = z / t
    if z % t != 0:
        r2 += 1
    r3 = x / a
    if x % a != 0:
        r3 += 1
    m = max(r1, r2, r3)
    z = t * m
    x = a * m

print z + x


Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User mugenen
Language Python (2.7.6)
Score 300
Code Size 958 Byte
Status AC
Exec Time 43 ms
Memory 4516 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 43 ms 4516 KB
0_001.txt AC 28 ms 4128 KB
0_002.txt AC 28 ms 4128 KB
1_003.txt AC 28 ms 4128 KB
1_004.txt AC 33 ms 4128 KB
1_005.txt AC 29 ms 4128 KB
1_006.txt AC 30 ms 4128 KB
1_007.txt AC 29 ms 4128 KB
1_008.txt AC 29 ms 4128 KB
1_009.txt AC 28 ms 4128 KB
1_010.txt AC 28 ms 4128 KB
1_011.txt AC 28 ms 4128 KB
1_012.txt AC 29 ms 4128 KB
1_013.txt AC 32 ms 4128 KB
1_014.txt AC 33 ms 4128 KB