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 Python2 (2.7.6)
Score 300
Code Size 958 Byte
Status
Exec Time 43 ms
Memory 4516 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 300 / 300 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 43 ms 4516 KB
0_001.txt 28 ms 4128 KB
0_002.txt 28 ms 4128 KB
1_003.txt 28 ms 4128 KB
1_004.txt 33 ms 4128 KB
1_005.txt 29 ms 4128 KB
1_006.txt 30 ms 4128 KB
1_007.txt 29 ms 4128 KB
1_008.txt 29 ms 4128 KB
1_009.txt 28 ms 4128 KB
1_010.txt 28 ms 4128 KB
1_011.txt 28 ms 4128 KB
1_012.txt 29 ms 4128 KB
1_013.txt 32 ms 4128 KB
1_014.txt 33 ms 4128 KB