CSES - Datatähti 2022 alku - Results
Submission details
Task:Tietoverkko
Sender:eaittok
Submission time:2021-10-12 16:58:29 +0300
Language:Python3 (CPython3)
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.02 s1, 2, 3details
#20.04 s2, 3details
#30.87 s3details

Code

def speed(connection):
    return connection[2]

ip = []
if True:
    n = int(input())
    ip.append(n)
    for _ in range(n-1):
        ip.append(input())
else:
    file = open("input.txt")
    for line in file:
        ip.append(line.strip())
    n = int(input[0])

#print(ip)
connections = []
for i in range(1, n):
    row = ip[i].split()
    connections.append((int(row[0]), int(row[1]), int(row[2])))

#print(connections)
connections.sort(key=speed, reverse=True)
#print(connections)

result = 0
for i in range(n-1):
    result += (i+1)*connections[i][2]

print(result)

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
100
1 2 74
1 3 100
2 4 50
3 5 40
...

correct output
88687

user output
162632

Test 2

Group: 2, 3

Verdict:

input
5000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1103702320243776

user output
4183854306632911

Test 3

Group: 3

Verdict:

input
200000
1 2 613084013
1 3 832364259
2 4 411999902
3 5 989696303
...

correct output
1080549209850010931

user output
6652407974595782384