CSES - Aalto Competitive Programming 2024 - wk10 - Wed - Results
Submission details
Task:Gas tank
Sender:aalto2024k_002
Submission time:2024-11-13 17:21:32 +0200
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.04 sdetails
#2ACCEPTED0.04 sdetails
#30.04 sdetails
#40.04 sdetails
#50.04 sdetails
#60.04 sdetails
#70.04 sdetails
#80.04 sdetails
#90.04 sdetails
#100.04 sdetails
#110.04 sdetails
#120.04 sdetails
#130.04 sdetails
#140.04 sdetails
#150.04 sdetails
#160.04 sdetails
#170.04 sdetails
#180.04 sdetails
#190.04 sdetails
#20ACCEPTED0.04 sdetails
#210.04 sdetails
#220.04 sdetails
#230.04 sdetails
#240.04 sdetails
#250.04 sdetails
#260.04 sdetails
#270.04 sdetails
#280.04 sdetails
#290.04 sdetails
#300.04 sdetails
#310.04 sdetails
#320.04 sdetails
#330.04 sdetails
#340.04 sdetails
#350.04 sdetails
#360.04 sdetails
#370.04 sdetails
#380.04 sdetails
#390.04 sdetails
#400.04 sdetails
#410.04 sdetails
#420.04 sdetails
#430.04 sdetails
#440.04 sdetails
#450.04 sdetails
#460.04 sdetails
#470.04 sdetails
#480.04 sdetails
#490.04 sdetails
#500.04 sdetails
#510.05 sdetails
#520.05 sdetails
#530.05 sdetails
#540.05 sdetails
#550.05 sdetails
#560.05 sdetails
#570.05 sdetails
#580.05 sdetails
#590.05 sdetails
#600.05 sdetails
#610.13 sdetails
#620.16 sdetails
#630.09 sdetails
#640.08 sdetails
#650.09 sdetails
#660.14 sdetails
#670.08 sdetails
#680.13 sdetails
#690.07 sdetails
#700.16 sdetails
#710.13 sdetails
#720.12 sdetails
#730.15 sdetails
#740.10 sdetails
#750.07 sdetails
#760.12 sdetails
#770.15 sdetails
#780.07 sdetails
#790.11 sdetails
#800.14 sdetails

Code

import math

i = int(input())
tmp = math.floor(math.sqrt(i) / 2.0)
print(tmp)

def get_b(a, c):
    A = a
    B = a*a
    C = -c
    subsum = B*B - (4*A*C)
    if subsum < 0:
        return 0, 0
    f = -(B - math.sqrt(subsum)) / (2 * A)
    s = -(B + math.sqrt(subsum)) / (2 * A)
    if f > s:
        return math.floor(f), math.ceil(f)
    return math.floor(s), math.ceil(s)

best_a, best_b = 0, 0
best_vol = 0

# for os in range(-1000000, 1000000):
for a in range(1, tmp+1):
    for b in get_b(a, i):
        vol = a*a*b + a*b*b
        if vol <= i and vol > best_vol:
            best_vol = vol
            best_a = a
            best_b = b


print(int(best_b), int(best_a))

Test details

Test 1

Verdict: ACCEPTED

input
8

correct output
2 1

user output
1
2 1

Test 2

Verdict: ACCEPTED

input
7

correct output
2 1

user output
1
2 1

Test 3

Verdict:

input
46

correct output
6 1

user output
3
6 1

Test 4

Verdict:

input
28

correct output
4 1

user output
2
4 1

Test 5

Verdict:

input
40

correct output
5 1

user output
3
5 1

Test 6

Verdict:

input
34

correct output
5 1

user output
2
5 1

Test 7

Verdict:

input
39

correct output
5 1

user output
3
5 1

Test 8

Verdict:

input
38

correct output
5 1

user output
3
5 1

Test 9

Verdict:

input
25

correct output
4 1

user output
2
4 1

Test 10

Verdict:

input
26

correct output
4 1

user output
2
4 1

Test 11

Verdict:

input
549

correct output
7 6

user output
11
7 6

Test 12

Verdict:

input
418

correct output
13 2

user output
10
13 2

Test 13

Verdict:

input
436

correct output
6 6

user output
10
6 6

Test 14

Verdict:

input
551

correct output
7 6

user output
11
7 6

Test 15

Verdict:

input
968

correct output
21 2

user output
15
21 2

Test 16

Verdict:

input
222

correct output
14 1

user output
7
14 1

Test 17

Verdict:

input
893

correct output
13 4

user output
14
13 4

Test 18

Verdict:

input
77

correct output
8 1

user output
4
8 1

Test 19

Verdict:

input
874

correct output
29 1

user output
14
29 1

Test 20

Verdict: ACCEPTED

input
11

correct output
2 1

user output
1
2 1

Test 21

Verdict:

input
772

correct output
12 4

user output
13
12 4

Test 22

Verdict:

input
181

correct output
5 4

user output
6
5 4

Test 23

Verdict:

input
155

correct output
11 1

user output
6
11 1

Test 24

Verdict:

input
778

correct output
12 4

user output
13
12 4

Test 25

Verdict:

input
514

correct output
15 2

user output
11
15 2

Test 26

Verdict:

input
849

correct output
8 7

user output
14
8 7

Test 27

Verdict:

input
224

correct output
14 1

user output
7
14 1

Test 28

Verdict:

input
295

correct output
11 2

user output
8
11 2

Test 29

Verdict:

input
651

correct output
25 1

user output
12
25 1

Test 30

Verdict:

input
98

correct output
6 2

user output
4
6 2

Test 31

Verdict:

input
588264

correct output
172 18

user output
383
172 18

Test 32

Verdict:

input
48736

correct output
80 7

user output
110
80 7

Test 33

Verdict:

input
208508

correct output
99 18

user output
228
99 18

Test 34

Verdict:

input
517415

correct output
172 16

user output
359
172 16

Test 35

Verdict:

input
960234

correct output
290 11

user output
489
290 11

Test 36

Verdict:

input
870321

correct output
111 49

user output
466
111 49

Test 37

Verdict:

input
308005

correct output
70 40

user output
277
70 40

Test 38

Verdict:

input
425818

correct output
652 1

user output
326
652 1

Test 39

Verdict:

input
729178

correct output
83 61

user output
426
83 61

Test 40

Verdict:

input
863955

correct output
535 3

user output
464
535 3

Test 41

Verdict:

input
116086

correct output
340 1

user output
170
340 1

Test 42

Verdict:

input
612309

correct output
782 1

user output
391
782 1

Test 43

Verdict:

input
375142

correct output
228 7

user output
306
228 7

Test 44

Verdict:

input
852178

correct output
161 28

user output
461
161 28

Test 45

Verdict:

input
151667

correct output
156 6

user output
194
156 6

Test 46

Verdict:

input
196137

correct output
103 16

user output
221
103 16

Test 47

Verdict:

input
375254

correct output
612 1

user output
306
612 1

Test 48

Verdict:

input
451513

correct output
298 5

user output
335
298 5

Test 49

Verdict:

input
942864

correct output
122 46

user output
485
122 46

Test 50

Verdict:

input
848035

correct output
215 17

user output
460
215 17

Test 51

Verdict:

input
727949226

correct output
1876 188

user output
13490
1876 188

Test 52

Verdict:

input
119540561

correct output
395 387

user output
5466
395 387

Test 53

Verdict:

input
168568700

correct output
447 430

user output
6491
447 430

Test 54

Verdict:

input
747828096

correct output
2098 158

user output
13673
2098 158

Test 55

Verdict:

input
113886324

correct output
949 113

user output
5335
949 113

Test 56

Verdict:

input
544092912

correct output
2620 77

user output
11662
2620 77

Test 57

Verdict:

input
112927706

correct output
532 266

user output
5313
532 266

Test 58

Verdict:

input
562461747

correct output
1803 159

user output
11858
1803 159

Test 59

Verdict:

input
930544437

correct output
7390 17

user output
15252
7390 17

Test 60

Verdict:

input
612603672

correct output
1128 364

user output
12375
1128 364

Test 61

Verdict:

input
575864416073

correct output
7427 5843

user output
379428
7427 5843

Test 62

Verdict:

input
942935707814

correct output
63092 236

user output
485524
63092 236

Test 63

Verdict:

input
171264013251

correct output
14433 780

user output
206920
14433 780

Test 64

Verdict:

input
76712165827

correct output
8381 978

user output
138484
8381 978

Test 65

Verdict:

input
161612205399

correct output
7527 2206

user output
201005
7527 2206

Test 66

Verdict:

input
641183113758

correct output
50116 254

user output
400369
50116 254

Test 67

Verdict:

input
87822361843

correct output
24538 145

user output
148174
24538 145

Test 68

Verdict:

input
550401843854

correct output
14093 2372

user output
370945
14093 2372

Test 69

Verdict:

input
56603972680

correct output
10404 499

user output
118957
10404 499

Test 70

Verdict:

input
991404337870

correct output
109250 83

user output
497846
109250 83

Test 71

Verdict:

input
534149659344

correct output
53496 186

user output
365427
53496 186

Test 72

Verdict:

input
336010906011

correct output
183301 10

user output
289832
183301 10

Test 73

Verdict:

input
871714540470

correct output
214186 19

user output
466828
214186 19

Test 74

Verdict:

input
254659717917

correct output
17240 818

user output
252319
17240 818

Test 75

Verdict:

input
40507166127

correct output
3335 2196

user output
100631
3335 2196

Test 76

Verdict:

input
445628406612

correct output
23039 811

user output
333777
23039 811

Test 77

Verdict:

input
822717753419

correct output
39363 524

user output
453518
39363 524

Test 78

Verdict:

input
40410210216

correct output
10096 382

user output
100511
10096 382

Test 79

Verdict:

input
366117794932

correct output
49165 151

user output
302538
49165 151

Test 80

Verdict:

input
657992849714

correct output
11698 3662

user output
405583
11698 3662