2006 | 2022-12-13 21:52:55 | neszbal | Városnézés | python3 | Wrong answer 0/100 | 342ms | 12776 KiB |
def minimize_phi(n, k, sequence, distances):
# Initialize the current value of the phi coefficient.
phi = 0
for i in range(n):
for j in range(i + 1, n):
if sequence[i] > sequence[j]:
phi += 1
# Iterate over the allowed distances.
for d in distances:
# Check all pairs of attractions that are d positions apart.
for i in range(n - d):
j = i + d
if sequence[i] > sequence[j]:
# If the order of the attractions would result in a higher phi coefficient,
# we can swap them to decrease the phi coefficient.
sequence[i], sequence[j] = sequence[j], sequence[i]
phi -= 1
return sequence
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = list(map(int, input().split()))
print(minimize_phi(n,k, a, d))
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 17ms | 10880 KiB | ||||
2 | Wrong answer | 17ms | 11708 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Wrong answer | 16ms | 11528 KiB | ||||
4 | Wrong answer | 17ms | 11636 KiB | ||||
5 | Wrong answer | 16ms | 11632 KiB | ||||
6 | Wrong answer | 16ms | 11812 KiB | ||||
7 | Wrong answer | 16ms | 11916 KiB | ||||
subtask3 | 0/30 | ||||||
8 | Wrong answer | 17ms | 11944 KiB | ||||
9 | Wrong answer | 17ms | 12392 KiB | ||||
10 | Wrong answer | 17ms | 12476 KiB | ||||
11 | Wrong answer | 17ms | 12680 KiB | ||||
12 | Wrong answer | 17ms | 12776 KiB | ||||
subtask4 | 0/60 | ||||||
13 | Time limit exceeded | 300ms | 6144 KiB | ||||
14 | Time limit exceeded | 263ms | 6340 KiB | ||||
15 | Time limit exceeded | 279ms | 6344 KiB | ||||
16 | Time limit exceeded | 342ms | 6664 KiB | ||||
17 | Time limit exceeded | 259ms | 6896 KiB | ||||
18 | Time limit exceeded | 275ms | 6832 KiB | ||||
19 | Time limit exceeded | 270ms | 7024 KiB | ||||
20 | Time limit exceeded | 279ms | 6808 KiB | ||||
21 | Time limit exceeded | 263ms | 6996 KiB | ||||
22 | Time limit exceeded | 282ms | 7108 KiB |