Problem:


宅配料金

ある宅配業者の宅配料金は大きさと重量で下表のように料金が設定されています。

A サイズ
B サイズ
C サイズ
D サイズ
E サイズ
F サイズ

大きさ
60cm以内
80cm以内
100cm以内
120cm以内
140cm以内
160cm以内

重さ
2kg以内
5kg以内
10kg以内
15kg以内
20kg以内
25kg以内

料金
600円
800円
1000円
1200円
1400円
1600円

大きさは三辺（縦、横、高さ）の和です。例えば大きさが120cmで、重さが15kg以内の荷物はＤサイズ（1,200円）となります。大きさが120cm以内でも、重さが15kgを超え、20kg以内ならばＥサイズとなります。

1日に持ち込まれた荷物の情報を入力とし、料金の総計を出力するプログラムを作成してください。なお、Ｆサイズを超えた荷物は対象外とし料金の総計には含みません。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりはゼロひとつの行で示されます。
各データセットは以下の形式で与えられます。

n
x1 y1 h1 w1
x2 y2 h2 w2
:
xn yn hn wn

１行目に荷物の個数n (1 ≤ n ≤ 10000)、続くn 行に i 番目の荷物の縦の長さ xi、横の長さ yi、高さ hi、重さ wi (1 ≤ xi, yi, hi, wi ≤ 200) が空白区切りで１行に与えられます。

データセットの数は 20 を超えません。

Output

データセットごとに荷物の料金の総計を１行に出力します。

Sample Input

2
50 25 5 5
80 60 10 30
3
10 15 25 24
5 8 12 5
30 30 30 18
0

Output for the Sample Input

800
3800



Sample input:
2
50 25 5 5
80 60 10 30
3
10 15 25 24
5 8 12 5
30 30 30 18
0


Sample output:
800
3800

Submission status: Wrong Answer

Solution code:
def f(x, y):
  x = 6
  for a, b in zip(A, B)[::-1]:
    if x > a or y > b: break
    x -= 1
  return x

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    rank = f(x+y+h, w)
    if rank<6: s += C[rank]
  print s

Submission status: Wrong Answer

Solution code:
def f(x, y):
  x = 6
  for a, b in zip(A, B):
    if x <= a and y <= b: x -= 1
  return x

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = f(x+y+h, w)
    if r<6: s += C[r]
  print s

Submission status: Wrong Answer

Solution code:
while True:
    try:
        t = 0
        for i in range(input()):
            x, y, h, w = map(int, raw_input().split())
            if x+y+h <= 60 and w <= 2:
                t += 600
            elif x+y+h <= 80 and w <= 5:
                t += 800
            elif x+y+h <= 100 and w <= 10:
                t += 1000
            elif x+y+h <= 120 and w <= 15:
                t += 1200
            elif x+y+h <= 140 and w <= 20:
                t += 1400
            elif x+y+h <= 160 and w <= 25:
                t += 1600
        else:
            print t
    except EOFError:
        break

Submission status: Wrong Answer

Solution code:
size = [60,80,100,120,140,160]        
weight = [2,5,10,16,20,25]
fee= [600,800,1000,1200,1400,1600]
while True:
    n = int(input())
    if n==0:
        break
    total = 0
    for _ in range(n):
        [x,y,h,wt] = list(map(int, input().split()))
        sz = x+y+h
        if sz > size[-1] or wt > weight[-1]:
            #print("NotAccept")
            continue
        isz = len(list(filter(lambda x: x<sz,   size)))
        iwt = len(list(filter(lambda x: x<wt, weight)))
        f   = fee[max(isz,iwt)]
        #print("%d %d %d %d %d" % (x,y,h,wt,f))
        total += f

    print(total)

Submission status: Wrong Answer

Solution code:
size = [60,80,100,120,140,160]        
weight = [2,5,10,16,20,25]
fee= [600,800,1000,1200,1400,1600]
while True:
    n = int(input())
    if n==0:
        break
    total = 0
    for _ in range(n):
        [x,y,h,wt] = list(map(int, input().strip().split()))
        sz = x+y+h
        if sz <= size[-1] and wt <= weight[-1]:
            isz = len(list(filter(lambda x: x<sz,   size)))
            iwt = len(list(filter(lambda x: x<wt, weight)))
            f   = fee[max(isz,iwt)]
            #print("%d %d %d %d %d" % (x,y,h,wt,f))
            total += f
    print(total)

Submission status: Wrong Answer

Solution code:
size = [60,80,100,120,140,160]        
weight = [2,5,10,16,20,25]
fee= [600,800,1000,1200,1400,1600]
while True:
    n = int(input())
    if n==0:
        break
    total = 0
    for _ in range(n):
        [x,y,h,wt] = list(map(float, input().strip().split()))
        sz = x+y+h
        if sz <= size[-1] and wt <= weight[-1]:
            isz = len(list(filter(lambda x: x<sz,   size)))
            iwt = len(list(filter(lambda x: x<wt, weight)))
            f   = fee[max(isz,iwt)]
            #print("%d %d %d %d %d" % (x,y,h,wt,f))
            total += f
    print(total)

Submission status: Wrong Answer

Solution code:
while True:
    e=0
    k=0
    l=0
    kk=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        ans1=0
        ans2=0
        a,b,c,d=0,0,0,0
        a,b,c,d=map(int,input().split())
        a=a+b+c
        if a<=60:
            ans1=1
        elif a<=80:
            ans1=2
        elif a<=100:
            ans1=3
        elif a<=120:
            ans1=4
        elif a<=140:
            ans1=5
        elif a<=160:
            ans1=6
        else:
            kk=1
        if d<=2:
            ans2=1
        elif d<=5:
            ans2=2
        elif d<=10:
            ans=3
        elif d<=15:
            ans2=4
        elif d<=20:
            ans2=5
        elif d<=25:
            ans2=6
        else:
            kk=1
        if ans1<ans2:
            e=ans2
        elif ans1>ans2:
            e=ans1
        elif ans1==ans2:
            e=ans1
        if kk==1:
            k=0
        elif e==6:
            k=1600
        elif e==5:
            k=1400
        elif e==4:
            k=1200
        elif e==3:
            k=1000
        elif e==2:
            k=800
        elif e==1:
            k=600
        else:
            k=0
        l+=k
    print(l)

Submission status: Wrong Answer

Solution code:
while True:
    e=0
    k=0
    po=0
    kk=0
    n=int(input())
    if n==0:
        break
    for i in range(n):
        ans1=0
        ans2=0
        a,b,c,d=0,0,0,0
        a,b,c,d=map(int,input().split())
        a=a+b+c
        if a<=60:
            ans1=1
        elif a<=80:
            ans1=2
        elif a<=100:
            ans1=3
        elif a<=120:
            ans1=4
        elif a<=140:
            ans1=5
        elif a<=160:
            ans1=6
        else:
            kk=1
        if d<=2:
            ans2=1
        elif d<=5:
            ans2=2
        elif d<=10:
            ans=3
        elif d<=15:
            ans2=4
        elif d<=20:
            ans2=5
        elif d<=25:
            ans2=6
        else:
            kk=1
        if ans1<ans2:
            e=ans2
        elif ans1>ans2:
            e=ans1
        elif ans1==ans2:
            e=ans1
        if kk==1:
            k=0
        elif e==6:
            k=1600
        elif e==5:
            k=1400
        elif e==4:
            k=1200
        elif e==3:
            k=1000
        elif e==2:
            k=800
        elif e==1:
            k=600
        else:
            k=0
        po+=k
    print(po)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
S = [60,80,100,120,140,160]
W = [2,5,10,15,20,25]
F = [600,800,1000,1200,1400,1600,0]
def func(x,y,h,w):
    return F[max(bisect_left(S,max(x,y,h)),bisect_left(W,w))]
while True:
    n = input()
    if n == 0:
        break
    print sum(func(*map(int,raw_input().split())) for _ in xrange(n))

Submission status: Wrong Answer

Solution code:
INF = 10000000000
sl = [0,   60,  80,  100,  120,  140,  160,  INF]
wl = [0,   2,   5,   10,   15,   20,   25,   INF]
pl = [600, 800, 1000, 1200, 1400, 1600, 0  ]

def le(n, l):
  for i, v in enumerate(l):
    if v >= n:
      return i - 1

while True:
  N = input()
  if not N:
    break
  s = 0
  for i in range(N):
    x, y, h, w = map(int, raw_input().split())
    s += pl[max(le(max(x, y, h), sl), le(w, wl))]
  print(s)

Submission status: Wrong Answer

Solution code:
INF = 10000000000
sl = [60,  80,  100,  120,  140,  160,  INF]
wl = [2,   5,   10,   15,   20,   25,   INF]
pl = [600, 800, 1000, 1200, 1400, 1600, 0  ]

def le(n, l):
  for i, v in enumerate(l):
    if v >= n:
      return i

while True:
  N = input()
  if not N:
    break
  s = 0
  for i in range(N):
    x, y, h, w = map(int, raw_input().split())
    s += pl[max(le(max(x, y, h), sl), le(w, wl))]
  print(s)

Submission status: Accepted

Solution code:
while True:
    counter = int(input())
    if counter == 0:
        break
    deliv_price = 0
    for i in range(0,counter):
        data = input().split(" ")
        size = int(data[0]) + int(data[1]) + int(data[2])
        weight = int(data[3])

        if size <= 60 and weight <= 2:
            deliv_price += 600
        elif size <= 80 and weight <=5:
            deliv_price += 800
        elif size <= 100 and weight <=10:
            deliv_price += 1000
        elif size <= 120 and weight <=15:
            deliv_price += 1200
        elif size <= 140 and weight <=20:
            deliv_price += 1400
        elif size <= 160 and weight <=25:
            deliv_price += 1600
    print(deliv_price)

Submission status: Accepted

Solution code:
while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x,y,h,w = map(int, raw_input().split())
    rank = max(max(5-(160-x-y-h)/20,0), [0,5-(25-w)/5][w>2])
    if rank < 6: s+= 600 + rank*200
  print s

Submission status: Accepted

Solution code:
while 1:
  n = input()
  if n==0: break
  A = []
  for _ in [0]*n:
    x,y,h,w = map(int, raw_input().split())
    a = max(5-(160-x-y-h)/20, 0)
    b = 5-(25-w)/5 if w>2 else 0
    A.append(max(a, b))
  print sum([600 + e*200  for e in A if e<6])

Submission status: Accepted

Solution code:
def f(x):
  A = []
  for i,e in enumerate(x): A += [i]*e
  return A

A = f([61]+[20]*5)
B = f([3]*2+[5]*4)
C = range(600,1800,200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    size = x + y + h
    if size <161 and w < 26:
      s += C[max(A[size], B[w])]
  print s

Submission status: Accepted

Solution code:
def f(x, y):
  c = 6
  for a, b in zip(A, B):
    if x <= a and y <= b: c -= 1
  return c

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = f(x+y+h, w)
    if r<6: s += C[r]
  print s

Submission status: Accepted

Solution code:
def f(x, y):
  c = 6
  for a, b in zip(A, B)[::-1]:
    if x > a or y > b: break
    c -= 1
  return c

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = f(x+y+h, w)
    if r<6: s += C[r]
  print s

Submission status: Accepted

Solution code:
A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = int(raw_input())
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = 0
    size = x + y + h
    for a, b in zip(A, B):
      if size > a or w > b: r+=1
      else: break
    if r<6: s += C[r]
  print s

Submission status: Accepted

Solution code:
A = zip(range(60, 180, 20), [2] + range(5, 30, 5))
C = range(600, 1800, 200)

while 1:
  n = int(raw_input())
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = 0
    size = x + y + h
    for a, b in A:
      if size > a or w > b: r+=1
      else: break
    if r<6: s += C[r]
  print s

Submission status: Accepted

Solution code:
while True:
    N = int(raw_input())
    if N == 0: break
    t = 0
    for i in range(N):
        x, y, h, w = map(int, raw_input().split())
        if x+y+h <= 60 and w <= 2:
            t += 600
        elif x+y+h <= 80 and w <= 5:
            t += 800
        elif x+y+h <= 100 and w <= 10:
            t += 1000
        elif x+y+h <= 120 and w <= 15:
            t += 1200
        elif x+y+h <= 140 and w <= 20:
            t += 1400
        elif x+y+h <= 160 and w <= 25:
            t += 1600
    else:
        print t

Submission status: Accepted

Solution code:
while True:
    s_m = 0
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        x,y,h,w = map(int,input().split())
        if x + y + h <= 60 and w <= 2:
            s_m += 600
        elif x + y + h <= 80 and w <= 5:
            s_m += 800
        elif x + y + h <= 100 and w <= 10:
            s_m += 1000
        elif x + y + h <= 120 and w <= 15:
            s_m += 1200
        elif x + y + h <= 140 and w <= 20:
            s_m += 1400
        elif x + y + h <= 160 and w <= 25:
            s_m += 1600
    print(s_m)

Submission status: Accepted

Solution code:
while True:
    n= int(input())
    if n== 0: break
    ans= 0
    for _ in range(n):
        x, y, h, w= map(int, input().split())
        t= x+y+h
        if t<=60:
            s= "A" if w<=2 else("B" if w<=5 else("C" if w<=10 else("D" if w<= 15 else("E" if w<=20 else("F" if w<=25 else "G")))))
        elif t<=80:
            s= "B" if w<=5 else("C" if w<=10 else("D" if w<=15 else("E" if w<= 20 else("F" if w<=25 else "G"))))
        elif t<=100:
            s= "C" if w<=10 else("D" if w<=15 else("E" if w<=20 else("F" if w<= 25 else "G")))
        elif t<=120:
            s= "D" if w<=15 else("E" if w<=20 else("F" if w<=25 else "G"))
        elif t<=140:
            s= "E" if w<=20 else("F" if w<=25 else "G")
        elif t<=160 and w<=25:
            s= "F"
        else:
            s= "G"
        v= 600 if s=="A" else(800 if s=="B" else(1000 if s=="C" else(1200 if s=="D" else(1400 if s=="E" else(1600 if s=="F" else 0)))))
        ans+= v
    print(ans)

Submission status: Accepted

Solution code:
while 1:
    n,v=int(input()),0
    if n==0:break
    for _ in range(n):
        x,y,h,w=map(int,input().split())
        x=x+y+h
        if x<61 and w<3:v+=600
        elif x<81 and w<6:v+=800
        elif x<101 and w<11:v+=1000
        elif x<121 and w<16:v+=1200
        elif x<141 and w<21:v+=1400
        elif x<161 and w<26:v+=1600
    print(v)

Submission status: Accepted

Solution code:
while 1:
    n,v=int(input()),0
    if n==0:break
    for _ in range(n):
        x,y,h,w=map(int,input().split())
        x=x+y+h
        if x<61 and w<3:v+=6
        elif x<81 and w<6:v+=8
        elif x<101 and w<11:v+=10
        elif x<121 and w<16:v+=12
        elif x<141 and w<21:v+=14
        elif x<161 and w<26:v+=16
    print(v*100)

Submission status: Accepted

Solution code:
size = [60,80,100,120,140,160]        
weight = [2,5,10,15,20,25]
fee= [600,800,1000,1200,1400,1600]
while True:
    n = int(input())
    if n==0:
        break
    total = 0
    for _ in range(n):
        [x,y,h,wt] = list(map(int, input().strip().split()))
        sz = x+y+h
        if sz <= size[-1] and wt <= weight[-1]:
            isz = len(list(filter(lambda x: x<sz,   size)))
            iwt = len(list(filter(lambda x: x<wt, weight)))
            f   = fee[max(isz,iwt)]
            #print("%d %d %d %d %d" % (x,y,h,wt,f))
            total += f
    print(total)

Submission status: Accepted

Solution code:
S = [60, 80, 100, 120, 140, 160]
W = [2, 5, 10, 15, 20, 25]
P = [600, 800, 1000, 1200, 1400, 1600]

while 1:
    n = int(input())
    if n == 0:
        break
    r = 0
    for i in range(n):
        x, y, h, w = map(int, input().split())
        s = x + y + h
        for j in range(6):
            if s <= S[j] and w <= W[j]:
                r += P[j]
                break
    print(r)

Submission status: Accepted

Solution code:
# Aizu Problem 00160: Delivery Fee
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


tariff = {'A': {"size":  60, "weight":  2, "price":  600},
          'B': {"size":  80, "weight":  5, "price":  800},
          'C': {"size": 100, "weight": 10, "price": 1000},
          'D': {"size": 120, "weight": 15, "price": 1200},
          'E': {"size": 140, "weight": 20, "price": 1400},
          'F': {"size": 160, "weight": 25, "price": 1600}}

def get_fee(s, w):
    for t in ['A', 'B', 'C', 'D', 'E', 'F']:
        if s <= tariff[t]["size"] and w <= tariff[t]["weight"]:
            return tariff[t]["price"]
    return 0

    
while True:
    n = int(input())
    if n == 0:
        break
    fee = 0
    for _ in range(n):
        x, y, z, w = [int(__) for __ in input().split()]
        s = x + y + z
        fee += get_fee(s, w)
    print(fee)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0160

"""
import sys
from sys import stdin
from collections import namedtuple
from bisect import bisect_left
input = stdin.readline
price = namedtuple('price', ['size', 'weight', 'cost'])


def main(args):
    prices = [price(60, 2, 600), price(80, 5, 800), price(100, 10, 1000), price(120, 15, 1200),
              price(140, 20, 1400), price(160, 25, 1600), price(float('inf'), float('inf'), 0)]

    while True:
        n = int(input())
        if n == 0:
            break

        s_key = [x[0] for x in prices]
        w_key = [x[1] for x in prices]
        total = 0
        for _ in range(n):
            x, y, h, w = map(int, input().split())
            i = bisect_left(s_key, x+y+h)
            j = bisect_left(w_key, w)
            total += prices[max(i, j)].cost

        print(total)



if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0160
AC
"""
import sys
from sys import stdin
from collections import namedtuple
from bisect import bisect_left
input = stdin.readline
price = namedtuple('price', ['size', 'weight', 'cost'])


def main(args):
    prices = [price(60, 2, 600), price(80, 5, 800), price(100, 10, 1000), price(120, 15, 1200),
              price(140, 20, 1400), price(160, 25, 1600), price(float('inf'), float('inf'), 0)]

    while True:
        n = int(input())
        if n == 0:
            break

        s_key = [x.size for x in prices]
        w_key = [x.weight for x in prices]
        total = 0
        for _ in range(n):
            x, y, h, w = map(int, input().split())
            i = bisect_left(s_key, x+y+h)
            j = bisect_left(w_key, w)
            total += prices[max(i, j)].cost

        print(total)



if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
SENTINEL = 9999
SIZE = (60, 80, 100, 120, 140, 160, SENTINEL)
WEIGHT = (2, 5, 10, 15, 20, 25, SENTINEL)
PRICE = (600, 800, 1000, 1200, 1400, 1600, SENTINEL)


def check(item, base_list, output):
    for index, base in enumerate(base_list):
        if item <= base:
            return output[index]


while True:

    input_count = int(input())

    if input_count == 0:
        break

    sum = 0

    for _ in range(input_count):
        vertical, horizontal, height, weight = [int(item) for item in input().split(" ")]
        size = vertical + horizontal + height

        price = max(check(size, SIZE, PRICE), check(weight, WEIGHT, PRICE))

        if price != SENTINEL:
            sum += price

    print(sum)

Submission status: Accepted

Solution code:
# AOJ 0160 Delivery Fee
# Python3 2018.6.18 bal4u


tbl = [ 600, 800, 1000, 1200, 1400, 1600 ]

while True:
	n = int(input())
	if n == 0: break
	fee = 0
	for i in range(n):
		x, y, h, w = list(map(int, input().split()))
		s = x+y+h
		if s <= 160 and w <= 25:
			k1 = k2 = 0
			if s <= 60: k1 = 0
			else: k1 = (s-61)//20 + 1
			if w <= 2: k2 = 0;
			else: k2 = (w-1)//5 + 1
			if k1 < k2: k1 = k2
			fee += tbl[k1]
	print(fee)

Submission status: Accepted

Solution code:
def charge(x, y, h, w):
  size = x + y + h
  if size <= 60 and w <= 2:
    return 600
  elif size <= 80 and w <= 5:
    return 800
  elif size <= 100 and w <= 10:
    return 1000
  elif size <= 120 and w <= 15:
    return 1200
  elif size <= 140 and w <= 20:
    return 1400
  elif size <= 160 and w <= 25:
    return 1600
  else:
    return 0
while True:
  n = int(input())
  if n == 0:
    break
  
  c_sum = 0 
  for _ in range(n):
    x, y, h, w = map(int, input().split())
    c_sum += charge(x, y, h, w)
  print(c_sum)

Submission status: Accepted

Solution code:
while 1:
    n=input()
    if n==0:break
    value=0
    for i in range(n):
        x,y,h,w=map(int,raw_input().split())
        size=x+y+h
        if size<=60 and w<=2:value+=600
        elif size<=80 and w<=5:value+=800
        elif size<=100 and w<=10:value+=1000
        elif size<=120 and w<=15:value+=1200
        elif size<=140 and w<=20:value+=1400
        elif size<=160 and w<=25:value+=1600
    print value

Submission status: Accepted

Solution code:
T=zip(range(60,161,20),[2]+range(5,26,5),range(600,1601,200))
while True:
    n=input()
    if n==0:break
    cnt=0
    for p in range(n):
        x,y,h,w=map(int,raw_input().split())
        size=x+y+h
        for i,j,k in T:
            if size<=i and w<=j:
                cnt+=k
                break
    print cnt

Submission status: Accepted

Solution code:
from bisect import bisect_left
S = [60,80,100,120,140,160]
W = [2,5,10,15,20,25]
F = [600,800,1000,1200,1400,1600,0]
def func(x,y,h,w):
    return F[max(bisect_left(S,x+y+h),bisect_left(W,w))]
while True:
    n = input()
    if n == 0:
        break
    print sum(func(*map(int,raw_input().split())) for _ in xrange(n))

Submission status: Accepted

Solution code:
size = [60,80,100,120,140,160]
weight = [2,5,10,15,20,25]
cost = [6,8,10,12,14,16]
while True:
	n = int(raw_input())
	if n == 0: break
	ans = 0
	for i in range(n):
		x,y,h,w = map(int, raw_input().split())
		xyh = x+y+h
		for j in range(6):
			if xyh <= size[j] and w <= weight[j]:
				ans += cost[j]*100
				break
	print ans

Submission status: Accepted

Solution code:
INF = 10000000000
sl = [60,  80,  100,  120,  140,  160,  INF]
wl = [2,   5,   10,   15,   20,   25,   INF]
pl = [600, 800, 1000, 1200, 1400, 1600, 0  ]

def le(n, l):
  for i, v in enumerate(l):
    if v >= n:
      return i

while True:
  N = input()
  if not N:
    break
  s = 0
  for i in range(N):
    x, y, h, w = map(int, raw_input().split())
    s += pl[max(le(x + y + h, sl), le(w, wl))]
  print(s)

Submission status: Accepted

Solution code:
def ryoukin(x, y, h, w) :
    length = x + y + h
    if length <= 60 and w <= 2 :
        return 600
    elif length <= 80 and w <= 5 :
        return 800
    elif length <= 100 and w <= 10 :
        return 1000
    elif length <= 120 and w <= 15 :
        return 1200
    elif length <= 140 and w <= 20 :
        return 1400
    elif length <= 160 and w <= 25 :
        return 1600
    else :
        return 0

while True :
    n = int(input())
    if n == 0 :
        break
    ans = 0
    for i in range(n) :
        x, y, h, w = map(int, input().split())
        ans += ryoukin(x, y, h, w)
    print(ans)

Submission status: Accepted

Solution code:
import sys
import math
j=0
while j<20:
    n=int(input())
    if(n==0):
        break
    i=0
    a=0
    b=0
    c=0
    d=0
    e=0
    f=0
    while i<n:
        x,y,h,w=map(int,input().split())
        size=x+y+h
        if(size<=60 and w<=2):
            a=a+1
        elif(size<=80 and w<=5):
            b=b+1
        elif(size<=100 and w<=10):
            c=c+1
        elif(size<=120 and w<=15):
            d=d+1
        elif(size<=140 and w<=20):
            e=e+1
        elif(size<=160 and w<=25):
            f=f+1
        i=i+1
    total_money=(a*600)+(b*800)+(c*1000)+(d*1200)+(e*1400)+(f*1600)
    print(str(total_money))

Submission status: Accepted

Solution code:
while True:
    n=int(input())
    if n==0:
        break
    s=0
    for i in range(n):
        x,y,h,w=map(int,input().split())
        k=x+y+h
        if k<=60 and w<=2:
            s+=600
        elif k<=80 and w<=5:
            s+=800
        elif k<=100 and w<=10:
            s+=1000
        elif k<=120 and w<=15:
            s+=1200
        elif k<=140 and w<=20:
            s+=1400
        elif k<=160 and w<=25:
            s+=1600
        else:
            pass
    print (s)

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n==0: break
    sum=0
    for i in range(n):
        x,y,h,w = map(int,input().split())
        l = x+y+h
        if l<=60 and w<=2:
            fee = 600    
        elif l<=80 and w<=5:
            fee=800
        elif l<=100 and w<=10:
            fee=1000
        elif l<=120 and w<=15:
            fee=1200
        elif l<=140 and w<=20:
            fee=1400
        elif l<=160 and w<=25:
            fee=1600
        else :
            fee=0
        sum += fee
        
    print(sum)

Submission status: Accepted

Solution code:
while True:
  n =int(input())
  if n==0:
    break
  ans=0
  for i in range(n): 
    x,y,h,w=map(int, input().split())
    size=x+y+h
    if size<=60 and w<=2:
      pay=600    
    elif size<=80 and w<=5:
      pay=800
    elif size<=100 and w<=10:
      pay=1000
    elif size<=120 and w<=15:
      pay=1200
    elif size<=140 and w<=20:
      pay=1400
    elif size<=160 and w<=25:
      pay=1600
    else:
      pay =0
    ans+=pay      
  print(ans)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break

    price = 0
    for _ in range(n):
        x, y, h, w = map(int, input().split())
        size = x + y + h

        if size <= 60 and w <= 2:
            price += 600
        elif size <= 80 and w <= 5:
            price += 800
        elif size <= 100 and w <= 10:
            price += 1000
        elif size <= 120 and w <= 15:
            price += 1200
        elif size <= 140 and w <= 20:
            price += 1400
        elif size <= 160 and w <= 25:
            price += 1600

    print(price)

Submission status: Accepted

Solution code:
def process(x, y, h, w):
    if x+y+h <= 60 and w <= 2:
        return 600
    elif x+y+h <= 80 and w <= 5:
        return 800
    elif x+y+h <= 100 and w <= 10:
        return 1000
    elif x+y+h <= 120 and w <= 15:
        return 1200
    elif x+y+h <= 140 and w <= 20:
        return 1400
    elif x+y+h <= 160 and w <= 25:
        return 1600
    else:
        return 0

result = []
while True:
    n = int(input())
    if n == 0: break
    total = 0
    for _ in range(n):
        x, y, h, w = map(int, input().split())
        total += process(x, y, h, w)
    result.append(total)
print('\n'.join(map(str, result)))

Submission status: Runtime Error

Solution code:
from bisect import bisect,bisect_left
from fractions import gcd
MAXN = 1000002
T = 2**20*3**14*5**9
H = filter(lambda i:gcd(T,i)==i,xrange(MAXN))
while True:
    line = raw_input()
    if line == "0":
        break
    m,n = map(int,line.split())
    print bisect(H,n)-bisect_left(H,m)