10722 | 2024-04-10 17:48:29 | 42 | Összegzések | python3 | Partially correct 66/100 | 32ms | 16864 KiB |
from sys import stdin
input=stdin.readline
def main():
N = int(input())
T = [int(x) for x in input().split()]
s=sum(T)
#print(N,T)
if N==1:
if s==1:
print(0)
print(0)
return
else:
print(0)
print(s-1,1)
return
if N==s:
print('2 '+'1 '*(N-2))
print(0)
return
#next
i=N-1
while i>=0 and T[i]==T[i-1]:
i-=1
if i==0:
print(T[0]+1,'1 '*(s-T[0]-1))
elif i==N-1:
# ... y y y>x
j=N-2
while j>=0 and T[j]==T[j-1]:
j-=1
print(*T[:j],T[j]+1,'1 '*(T[-2]*(N-2-j)+T[-1]-1))
else:
print(*T[:i],T[i]+1,'1 '*(T[i]*(N-i-1)-1))
#prev
i=N-1
while T[i]==1:
i-=1
# end: '1 '*(N-i)
n=(T[i]+N-i-1)//(T[i]-1)
r=(T[i]+N-i-1)%(T[i]-1)
#print('n,r:',n,r,i,T[i])
if r==0:
print(*T[:i],(str(T[i]-1)+' ')*n)
else:
print(*T[:i],(str(T[i]-1)+' ')*n+str(r))
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 18ms | 11592 KiB | ||||
2 | Accepted | 18ms | 12092 KiB | ||||
3 | Accepted | 18ms | 12508 KiB | ||||
subtask2 | 6/6 | ||||||
4 | Accepted | 17ms | 12024 KiB | ||||
5 | Accepted | 18ms | 12512 KiB | ||||
6 | Accepted | 17ms | 12568 KiB | ||||
7 | Accepted | 17ms | 12708 KiB | ||||
8 | Accepted | 18ms | 13040 KiB | ||||
subtask3 | 6/6 | ||||||
9 | Accepted | 18ms | 13328 KiB | ||||
10 | Accepted | 17ms | 13204 KiB | ||||
11 | Accepted | 18ms | 13396 KiB | ||||
12 | Accepted | 19ms | 13956 KiB | ||||
13 | Accepted | 19ms | 13788 KiB | ||||
subtask4 | 5/10 | ||||||
14 | Accepted | 18ms | 13328 KiB | ||||
15 | Accepted | 17ms | 13204 KiB | ||||
16 | Accepted | 18ms | 13396 KiB | ||||
17 | Accepted | 19ms | 13956 KiB | ||||
18 | Accepted | 19ms | 13788 KiB | ||||
19 | Partially correct | 18ms | 13632 KiB | ||||
20 | Partially correct | 18ms | 13824 KiB | ||||
21 | Partially correct | 30ms | 16184 KiB | ||||
22 | Partially correct | 30ms | 16864 KiB | ||||
23 | Partially correct | 32ms | 16720 KiB | ||||
subtask5 | 10/10 | ||||||
24 | Accepted | 17ms | 14444 KiB | ||||
25 | Accepted | 17ms | 14152 KiB | ||||
26 | Accepted | 17ms | 14416 KiB | ||||
27 | Accepted | 17ms | 14444 KiB | ||||
28 | Accepted | 17ms | 14588 KiB | ||||
subtask6 | 10/10 | ||||||
29 | Accepted | 17ms | 14544 KiB | ||||
30 | Accepted | 17ms | 14308 KiB | ||||
31 | Accepted | 17ms | 14052 KiB | ||||
32 | Accepted | 17ms | 14596 KiB | ||||
33 | Accepted | 17ms | 14344 KiB | ||||
subtask7 | 29/58 | ||||||
34 | Accepted | 17ms | 14372 KiB | ||||
35 | Accepted | 17ms | 14468 KiB | ||||
36 | Accepted | 18ms | 15144 KiB | ||||
37 | Accepted | 17ms | 12024 KiB | ||||
38 | Accepted | 18ms | 12512 KiB | ||||
39 | Accepted | 17ms | 12568 KiB | ||||
40 | Accepted | 17ms | 12708 KiB | ||||
41 | Accepted | 18ms | 13040 KiB | ||||
42 | Accepted | 18ms | 13328 KiB | ||||
43 | Accepted | 17ms | 13204 KiB | ||||
44 | Accepted | 18ms | 13396 KiB | ||||
45 | Accepted | 19ms | 13956 KiB | ||||
46 | Accepted | 19ms | 13788 KiB | ||||
47 | Partially correct | 18ms | 13632 KiB | ||||
48 | Partially correct | 18ms | 13824 KiB | ||||
49 | Partially correct | 30ms | 16184 KiB | ||||
50 | Partially correct | 30ms | 16864 KiB | ||||
51 | Accepted | 17ms | 14588 KiB | ||||
52 | Accepted | 17ms | 14544 KiB | ||||
53 | Accepted | 17ms | 14308 KiB | ||||
54 | Accepted | 17ms | 14052 KiB | ||||
55 | Accepted | 17ms | 14596 KiB | ||||
56 | Accepted | 17ms | 14344 KiB | ||||
57 | Accepted | 18ms | 15024 KiB | ||||
58 | Accepted | 17ms | 14780 KiB | ||||
59 | Accepted | 18ms | 14844 KiB | ||||
60 | Accepted | 17ms | 14852 KiB | ||||
61 | Accepted | 18ms | 14992 KiB | ||||
62 | Accepted | 18ms | 15332 KiB | ||||
63 | Accepted | 19ms | 15816 KiB | ||||
64 | Accepted | 21ms | 15700 KiB | ||||
65 | Accepted | 24ms | 15600 KiB | ||||
66 | Accepted | 27ms | 16000 KiB |