Skip to content

Commit

Permalink
real no time
Browse files Browse the repository at this point in the history
Signed-off-by: MisileLab <[email protected]>
  • Loading branch information
MisileLab committed Sep 19, 2023
1 parent 4d3ddac commit dac6e3f
Showing 1 changed file with 34 additions and 6 deletions.
40 changes: 34 additions & 6 deletions projects/xobusy/bojs/17954.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from math import ceil
#2n..2n-2 2n-1
#n..n-3 n-2 n-1
from copy import deepcopy
a, b = (False, False)
c = [[],[]]
d = int(input())
e = 0
_cac = ceil((d*2) / 4)

for i in range(1, d*2+1):
if a:
Expand All @@ -18,13 +19,40 @@
c[1].insert(-1, i)
a = not a
b = not b
t = ceil(i / 4)
e += (_cac-t) * i

if d % 2 == 1:
c[0].insert(-1, max(c[1][0], c[1][-1]))
c[1].remove(max(c[1][0], c[1][-1]))
t = 1
answer = deepcopy(c)

while len(c[0]) != 0 or len(c[1]) != 0:
try:
f = min(c[0][0], c[0][-1])
except IndexError:
g = min(c[1][0], c[1][-1])
c[1].remove(g)
for i in c:
for i2 in i:
e += t * i2
continue
try:
g = min(c[1][0], c[1][-1])
except IndexError:
c[0].remove(f)
for i in c:
for i2 in i:
e += t * i2
continue
if f <= g:
c[0].remove(f)
else:
c[1].remove(g)
for i in c:
for i2 in i:
e += t * i2
t += 1

print(e)
print(*c[0])
print(*c[1])
print(*answer[0])
print(*answer[1])

0 comments on commit dac6e3f

Please sign in to comment.