CSES - Putka Open 2015 – 3/6 - Results
Submission details
Task:Onnenluku
Sender:
Submission time:2015-09-11 16:57:11 +0300
Language:Python3
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.07 s1details
#20.08 s1details
#30.09 s1details
#40.09 s1details
#50.08 s1details
#60.07 s2details
#70.08 s2details
#80.09 s2details
#90.07 s2details
#100.10 s2details
#110.09 s3details
#120.07 s3details
#130.10 s3details
#140.08 s3details
#150.08 s3details

Code

#!/usr/bin/env python3

def laske(a, b, c, n):
    a, b, c = sorted((a, b, c))

    pienin_ero = min(c - b, b - a)
    if n <= pienin_ero:
        return a + n, b, c - n

    a, b, c = (a + pienin_ero), b, (c - pienin_ero)
    n -= pienin_ero

    # riittääkö tasoitukseen?
    ero = max(b, c) - min(a, b)
    if ero <= n:
        # riittää
        pienin = (a + b + c) // 3
        jakoj = (a + b + c) % 3
        a, b, c = pienin, pienin, pienin
        if jakoj > 0:
            c += 1
        if jakoj > 1:
            b += 1
        n -= ero
        if n % 2:
            a, b, c = a - 1, b, c + 1
    else:
        # print('ei riitä')
        # ei riitä
        if a == b:
            if n % 2 == 0:
                a, b, c = a + n // 2, b + n // 2, c - n
            else:
                a, b, c = a + n // 2, b + n // 2 + 1, c - n
        else:
            # b == c
            ero = b - a
            if n % 2 == 0:
                a, b, c = a + n, b - n // 2, c - n // 2
            else:
                a, b, c = a + n, b - n // 2 - 1, c - n // 2
    return (a, b, c)

def main():
    for i in range(int(input())):
        a, b, c, n = map(int, input().strip().split())
        print('%d %d %d' % laske(a, b, c, n))

if __name__ == '__main__':
    main()

Test details

Test 1

Group: 1

Verdict:

input
2157 93337

correct output
1421

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '2157 93337'

Test 2

Group: 1

Verdict:

input
4875 95124

correct output
1278

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '4875 95124'

Test 3

Group: 1

Verdict:

input
5577 96352

correct output
1245

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '5577 96352'

Test 4

Group: 1

Verdict:

input
8362 92950

correct output
1076

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '8362 92950'

Test 5

Group: 1

Verdict:

input
5658 96660

correct output
1238

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '5658 96660'

Test 6

Group: 2

Verdict:

input
51312303535233 994542403556353

correct output
1453976

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '51312303535233 994542403556353'

Test 7

Group: 2

Verdict:

input
25636920452341 934558290712847

correct output
1544072

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '25636920452341 934558290712847'

Test 8

Group: 2

Verdict:

input
7917952071965 985207415843573

correct output
1763176

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '7917952071965 985207415843573'

Test 9

Group: 2

Verdict:

input
48991581181227 907034837225965

correct output
1380248

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '48991581181227 907034837225965'

Test 10

Group: 2

Verdict:

input
47968703305149 924246001328437

correct output
1396632

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '47968703305149 924246001328437'

Test 11

Group: 3

Verdict:

input
292953755324413237753216241025...

correct output
53286731528535944

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '2929537553244132377532162410251823648052793051402 96463917346564188511882177515204779145810864670372'

Test 12

Group: 3

Verdict:

input
373990979330820426927419348165...

correct output
51580289482227600

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '3739909793308204269274193481652778070231729799623 97766875580288872905881695960460270094450336895482'

Test 13

Group: 3

Verdict:

input
701417326319476057561825658890...

correct output
42924933948374952

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '7014173263194760575618256588905321780224307828224 91832653840117061430228322343502759506423672596132'

Test 14

Group: 3

Verdict:

input
177202883511434557056457305647...

correct output
54500592365600640

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '1772028835114345570564573056473376348950033812085 91801935904110322340514736360767234352973177205455'

Test 15

Group: 3

Verdict:

input
977665117437419620152569155919...

correct output
38562071809359800

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 50, in <module>
    main()
  File "input/code.py", line 45, in main
    for i in range(int(input())):
ValueError: invalid literal for int() with base 10: '9776651174374196201525691559197038941654881320219 95075953292382735025808002911730639246390160004053'