2007 | 2022-12-13 21:58:41 | neszbal | Városnézés | python3 | Wrong answer 0/100 | 338ms | 12936 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)) # This is the function call
print(*minimize_phi(n,k, a, d))
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 17ms | 11108 KiB | ||||
2 | Accepted | 17ms | 11396 KiB | ||||
subtask2 | 0/10 | ||||||
3 | Accepted | 17ms | 11688 KiB | ||||
4 | Wrong answer | 17ms | 11896 KiB | ||||
5 | Accepted | 17ms | 11960 KiB | ||||
6 | Wrong answer | 17ms | 11992 KiB | ||||
7 | Wrong answer | 17ms | 12476 KiB | ||||
subtask3 | 0/30 | ||||||
8 | Wrong answer | 17ms | 12656 KiB | ||||
9 | Wrong answer | 17ms | 12760 KiB | ||||
10 | Wrong answer | 17ms | 12708 KiB | ||||
11 | Wrong answer | 17ms | 12720 KiB | ||||
12 | Accepted | 17ms | 12936 KiB | ||||
subtask4 | 0/60 | ||||||
13 | Time limit exceeded | 300ms | 6220 KiB | ||||
14 | Time limit exceeded | 282ms | 6092 KiB | ||||
15 | Time limit exceeded | 268ms | 6392 KiB | ||||
16 | Time limit exceeded | 270ms | 6660 KiB | ||||
17 | Time limit exceeded | 275ms | 6608 KiB | ||||
18 | Time limit exceeded | 279ms | 6568 KiB | ||||
19 | Time limit exceeded | 275ms | 6496 KiB | ||||
20 | Time limit exceeded | 270ms | 6820 KiB | ||||
21 | Time limit exceeded | 338ms | 6776 KiB | ||||
22 | Time limit exceeded | 268ms | 6708 KiB |