Problem:


科目選択 (Selecting Subjects)

 問題

JOI 君は物理，化学，生物，地学，歴史，地理の 6 科目のテストを受けた．
それぞれのテストは 100 点満点で採点された．

JOI 君は物理，化学，生物，地学の 4 科目から 3 科目を選択し，歴史，地理の 2 科目から 1 科目を選択する．

テストの合計点が最も高くなるように科目を選ぶとき，
JOI 君の選んだ科目のテストの合計点を求めよ．

  入力

入力は 6 行からなり，1 行に 1 つずつ整数が書かれている．

1 行目には JOI 君の物理のテストの点数 A が書かれている．

2 行目には JOI 君の化学のテストの点数 B が書かれている．

3 行目には JOI 君の生物のテストの点数 C が書かれている．

4 行目には JOI 君の地学のテストの点数 D が書かれている．

5 行目には JOI 君の歴史のテストの点数 E が書かれている．

6 行目には JOI 君の地理のテストの点数 F が書かれている．

書かれている整数 A, B, C, D, E, F はすべて 0 以上 100 以下である．

  出力

JOI 君が選んだ科目のテストの合計点を 1 行で出力せよ．

 入出力例

入力例 1

  

100
34
76
42
10
0

 
出力例 1

   

228

入力例 2

  

15
21
15
42
15
62

 
出力例 2

  

140

入出力例 1 では，JOI 君が物理，生物，地学，歴史の 4 科目を選ぶとき，テストの合計点が最高になる．

物理，生物，地学，歴史の点数はそれぞれ 100, 76, 42, 10 なので，選んだ科目のテストの合計点は 228 である．  

入出力例 2 では，JOI 君が化学，生物，地学，地理の 4 科目を選ぶとき，テストの合計点が最高になる．

化学，生物，地学，地理の点数はそれぞれ 21, 15, 42, 62 なので，選んだ科目のテストの合計点は 140 である．

入出力例 2 では，JOI 君が物理，化学，地学，地理の 4 科目を選ぶ場合でも，選んだテストの合計点は 140 である．

情報オリンピック日本委員会作 『第 15 回日本情報オリンピック JOI 2015/2016 予選競技課題』



Sample input:
100
34
76
42
10
0


Sample output:
228

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
A=[a,b,c,d]
B=[e,f]
x=sorted(A)
y=sorted(B)
print(x[3]+x[1]+x[2]+y[1])

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

sum1 = 0
sum2 = 0

if A <= B and A <= C and A <= D:
    sum1 = B+C+D
elif B <= A and B <= C and B <= D:
    sum1 = A+C+D
elif C <= A and C <= B and C <= D:
    sum1 = A+B+D
else:
    sum1 = A+B+C

if E <= F:
    sum2 = F
else:
    sum2 = E
    
print(sum1 + sum2)

Submission status: Accepted

Solution code:
a=[input() for i in range(6)]
for i in range(6):
    a[i]=int(a[i])
if a[0]>=a[1] and a[0]>=a[2] and a[0]>=a[3]:
    x=a[0]
    a.pop(0)
elif a[1]>=a[2] and a[1]>=a[3] and a[1]>=a[0]:
    x=a[1]
    a.pop(1)
elif a[2]>=a[3] and a[2]>=a[0] and a[2]>=a[1]:
    x=a[2]
    a.pop(2)
else:
    x=a[3]
    a.pop(3)

if a[0]>=a[1] and a[0]>=a[2]:
    y=a[0]
    a.pop(0)
elif a[1]>=a[2] and a[1]>=a[0]:
    y=a[1]
    a.pop(1)
else:
    y=a[2]
    a.pop(2)

if a[0]>=a[1]:
    z=a[0]
    a.pop(0)
else:
    z=a[1]
    a.pop(1)

if a[1]>=a[2]:
    w=a[1]
else:
    w=a[2]
print(x+y+z+w)

Submission status: Accepted

Solution code:

tmp = []

for i in range(4):  #物理，化学，生物，地学の 4 科目から 3 科目
    a = int(input())
    tmp.append(a)

list.sort(tmp,reverse=True)
sum1 = tmp[0]+tmp[1]+tmp[2]

b = int(input())
c = int(input())

print(sum1+max(b,c))

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())

list1=[a,b,c,d]
list2=[e,f]

list1.sort()
list2.sort()

print(list1[1]+list1[2]+list1[3]+list2[1])

Submission status: Accepted

Solution code:
a=[int(input()) for i in range(6)]
print(sum(a[0:4])-min(a[0:4]) + max(a[4],a[5]))

Submission status: Accepted

Solution code:
i=0
x=[0,0,0,0,0,0]
k=0
while i<6 :
    x[i]=int(input())
    i=1+i
while k<3 :
    if x[k]<x[k+1] : 
        ex=x[k]
        x[k]=x[k+1]
        x[k+1]=ex
    k=k+1
if int(x[4])<int(x[5]) : ave=x[0]+x[1]+x[2]+x[5]
else : ave=x[0]+x[1]+x[2]+x[4]
print(ave)

Submission status: Accepted

Solution code:
rika=[]
chiri=[]
for i in range(4):
    rika.append(int(input()))
    
for i in range(2):
    chiri.append(int(input()))

a=min(rika)
b=min(chiri)

kei=sum(rika)+sum(chiri)-a-b

print(kei)

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

list1 = []
list1.append(A)
list1.append(B)
list1.append(C)
list1.append(D)

list2 = []
list2.append(E)
list2.append(F)

for i in range(4):
    for j in range(3,0,-1):
        if list1[j-1]<list1[j]:
            list1[j-1],list1[j] = list1[j],list1[j-1]

if list2[0]<list2[1]:
    list2[0],list2[1] = list2[1],list2[0]

sumlist = []
sumlist.append(list1[0])
sumlist.append(list1[1])
sumlist.append(list1[2])
sumlist.append(list2[0])

print(sum(sumlist))

Submission status: Accepted

Solution code:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

X=[A, B, C, D]
Y=[E, F]

k = sorted(X)
del(k[0])
l = sorted(Y)
del(l[0])
    
n = sum(k)
m = sum(l)

print(n+m)

Submission status: Accepted

Solution code:
a=[0]*4
b=[0]*2

for i in range(4):
    a[i] = int(input())

a.sort()
del a[0]

for i in range(2):
    b[i]=int(input())
    
b.sort()
del b[0]
    
print(sum(a)+sum(b))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
F=int(input())

A,B,C,D=sorted([A,B,C,D])
E,F=sorted([E,F])

print(sum((B,C,D,F)))

Submission status: Accepted

Solution code:
a=[]
b=[]

for i in range(4):
  a.append(int(input()))
  a.sort(reverse=True)

for j in range(4,6):
  b.append(int(input()))
  b.sort(reverse=True)
  
print(sum(a[:3])+b[0])

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

try:
   l1 = []
   l2 = []
   for i in range(4):
      l1.append(int(input()))
      l1.sort()
      l1.reverse()
      
   for i in range(2):
      l2.append(int(input()))
      l2.sort()
      l2.reverse()
      
   print(sum(l1[0:3]) + l2[0])

except EOFError:
   pass

Submission status: Accepted

Solution code:
subjects = [int(input()) for _ in range(6)]
print(sum(sorted(subjects[:4])[-3:]) + sum(sorted(subjects[4:])[-1:]))

Submission status: Accepted

Solution code:
i = [int(input()) for i in range(4)]
j = [int(input()) for j in range(2)]
print(sum(i) - min(i) + max(j))

Submission status: Accepted

Solution code:
min_1=100; min_2=100
sum_1=0; sum_2=0

for i in range(4):
    a=int(input())
    sum_1+=a
    if a<min_1:
        min_1=a

sum_1=sum_1-min_1
    
for j in range(2):
    b=int(input())
    sum_2+=b
    if b<min_2:
        min_2=b
    
sum_2=sum_2-min_2
    
print(sum_1+sum_2)

Submission status: Accepted

Solution code:
x=[]
y=[]


for i in range (4):
    A=int(input())
    x.append(A)
x1=sorted(x,reverse=True)

for j in range (2):
    B=int(input())
    y.append(B)
y1=sorted(y,reverse=True)
   
   
print(x1[0]+x1[1]+x1[2]+y1[0])

Submission status: Accepted

Solution code:
x1=[]
y1=[]
for i in range(4):
    A=int(input())
    x1.append(A)
x=sorted(x1,reverse=True)
for j in range(2):
    E=int(input())
    y1.append(E)
y=sorted(y1,reverse=True)
sum=x[0]+x[1]+x[2]+y[0]
print(sum)

Submission status: Accepted

Solution code:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
x=[a,b,c,d]
s=sum(x)-min(x)
print(s+max(e,f))

Submission status: Accepted

Solution code:
y=[]
z=[]
for i in range(1,5):
    x=int(input())
    y.append(x)
y.remove(min(y))

for i in range(1,3):
    x=int(input())
    z.append(x)
z.remove(min(z))

print(int(y[0]+y[1]+y[2]+z[0]))

Submission status: Accepted

Solution code:
int_list = []
kei = 0
for num in range(4):
    inta = int(input())
    int_list.append(inta)
int_list.sort()
for num1 in range(1,4):
    kei += int_list[num1]
int_list = []
for num2 in range(2):
    inta = int(input())
    int_list.append(inta)
int_list.sort()
kei += int_list[1]
print(kei)

Submission status: Accepted

Solution code:
Si = []
So = []

for i in range(4) :
    p = int(input())
    Si.append(p)
    
for j in range(2) :
    p = int(input())
    So.append(p)
    
s = sum(Si) - min(Si) + sum(So) - min(So)

print(s)

Submission status: Accepted

Solution code:
import sys
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
num=[a,b,c,d]
s1=max(a,b,c,d)
s2=sorted(num)[-2]
s3=sorted(num)[-3]
i1=max(e,f)
s_sum=s1+s2+s3
total_max=s_sum+i1
print(total_max)

Submission status: Accepted

Solution code:
rikei = [int(input()) for i in range(4)]

for i in range(0, 4):
    for j in range(i + 1, 4):
        if rikei[i] < rikei[j]:
            tmp = rikei[i]
            rikei[i] = rikei[j]
            rikei[j] = tmp

bunkei = [int(input()) for i in range(2)]
if bunkei[0] < bunkei[1]:
    tmp = bunkei[0]
    bunkei[0] = bunkei[1]
    bunkei[1] = tmp

print(rikei[0] + rikei[1] + rikei[2] + bunkei[0])

Submission status: Accepted

Solution code:
L=list()
M=list()
for i in range(4):
  L.append(int(input()))
for i in range(2):
  M.append(int(input()))
L.sort()
M.sort()
print(M[-1]+sum(L[-3:]))

Submission status: Accepted

Solution code:
four, two = [], []
for _ in range(4):
    four.append(int(input()))
for _ in range(2):
    two.append(int(input()))

print(sum(sorted(four)[1:] + sorted(two)[1:]))

Submission status: Accepted

Solution code:
#A
sc = [int(input()) for i in range(4)]
so = [int(input()) for i in range(2)]
print(sum(sc)-min(sc)+max(so))

Submission status: Accepted

Solution code:
a = [int(input())for i in range(6)]
print(sum(a)-min(a[:4])-min(a[4:]))

Submission status: Accepted

Solution code:
A=[int(input()) for i in range(4)]
B=[int(input()) for i in range(2)]
A.sort()
print(sum(A[1:4])+max(B))

Submission status: Accepted

Solution code:
alist = []
blist = []
for i in range(4):
    a = int(input())
    alist.append(a)
for i in range(2):
    b = int(input())
    blist.append(b)
alist.sort()
blist.sort()
print(alist[1]+alist[2]+alist[3]+blist[1])

Submission status: Accepted

Solution code:
x = sorted([ int(input()) for i in range(4) ], reverse=True)
y = sorted([ int(input()) for i in range(2) ], reverse=True)
print(sum(x[:3])+sum(y[:1]))

Submission status: Accepted

Solution code:
a = []
b = []

for i in range(4):
    a.append(int(input()))
for i in range(2):
    b.append(int(input()))

print(sum(a)-min(a)+max(b))

Submission status: Accepted

Solution code:
L = []
for i in range(4):
    L.append(int(input()))

M = []
for i in range(2):
    M.append(int(input()))

L.sort(reverse=True)
M.sort(reverse=True)

print(sum(L[0:3])+M[0])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

X = [A, B, C, D]
X.sort()
ans = X[1] + X[2] + X[3] + max(E, F)
print(ans)

Submission status: Accepted

Solution code:
a=[int(input()) for _ in range(4)]
b=[int(input()) for _ in range(2)]
a.sort()
b.sort()
print(sum(a[1:])+b[1])

Submission status: Accepted

Solution code:
tmp_list1=[]
tmp_list2=[]
for i in range(4):
    num=int(input())
    tmp_list1.append(num)
    
for i in range(2):
    num=int(input())
    tmp_list2.append(num)
final_ans = sum(sorted(tmp_list1, reverse=True)[0:3])+max(tmp_list2)
print(final_ans)

Submission status: Accepted

Solution code:
abcdef = [int(input()) for i in range(6)]
abcd = abcdef[0:4]
ef = abcdef[4:6]

#print(abcd)
#print(ef)

def quicksort(list):
    if len(list) < 2:
        return list
    else:
        pivot = list[0]
        #pivotよりも小さい要素を全て含んだ部分配列
        less = [i for i in list[1:] if i <= pivot]
        #pivotよりも大きい要素を含んだ部分配列
        greater = [i for i in list[1:] if i > pivot]
        return quicksort(greater) + [pivot] + quicksort(less)

s_abcd = quicksort(abcd)
s_ef = quicksort(ef)

#print(s_abcd)
#print(s_ef)

sum = 0
for i in s_abcd[0:3]:
    sum = sum + i

best = sum + s_ef[0]
print(best)

Submission status: Accepted

Solution code:
a=[];exec("a.append(int(input()));"*4);print(max(int(input()),int(input()))+sum(sorted(a)[1:]))

Submission status: Accepted

Solution code:
science = []
for _ in range(4):
    score = int(input())
    science.append(score)

society = []
for _ in range(2):
    score = int(input())
    society.append(score)

science.sort()
society.sort()

total = sum(science[1:]) + society[1]
print(total)

Submission status: Accepted

Solution code:
flist = []
slist = []
for i in range(4):
    flist.append(int(input()))
for i in range(2):
    slist.append(int(input()))
    
mf = min(flist)
ms = min(slist)
flist.remove(mf)
slist.remove(ms)
print(sum(flist) + sum(slist))

Submission status: Accepted

Solution code:
rika=[]
shakai=[]
for i in range(4):
    r=int(input())
    rika.append(r)
    
for j in range(2):
    s=int(input())
    shakai.append(s)
    
rika.sort(reverse=True)
shakai.sort(reverse=True)

print(sum(rika)-min(rika)+shakai[0])

Submission status: Accepted

Solution code:
rika=[int(input()) for x in range(4)]
syakai=[int(input()) for x in range(2)]
print(sum(sorted(rika)[-3:])+sorted(syakai)[-1])

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
x = a + b + c + d + e + f
y = 100000
for i in (a,b,c,d):
 if y > i : y = i
z = 0
if e < f : z = f
else z = e
print (x - y - z)

Submission status: Runtime Error

Solution code:
a,b,c,d,e,f = map(int, input().split())
x = a + b + c + d + e + f
y = 100000
for i in (a,b,c,d):
 if y > i : y = i
z = 0
if e < f : z = f
else : z = e
print (x - y - z)

Submission status: Runtime Error

Solution code:
points = []
for _ in range(6):
    points.append(int(input())
print(sum(sorted(points, reverse=True)[:3]))

Submission status: Runtime Error

Solution code:
points = []
for i in range(6):
    points.append(int(input())
print(sum(sorted(points, reverse=True)[:3]))