107912024-04-12 20:07:4442Táblajáték 2 (70 pont)python3Partially correct 68/7018ms14124 KiB
from sys import stdin
input=stdin.readline

def main():
    N=int(input())
    K = [int(x) for x in input().split()]
    a=b=0
    for k in K:
        if k==4:
            b-=1
        elif k==5:
            b+=1
        elif k==0:
            a+=1
            b=b*3
        elif k==1:
            a+=1
            b=b*3+1
        elif k==2:
            a+=1
            b=b*3+2
        elif k==3:
            a-=1
            b//=3
    print(a)
    res=[]
    while b:
        res.append(str(b%3))
        b//=3
    print(''.join(res[::-1]))
        
main()
SubtaskSumTestVerdictTimeMemory
base68/70
1Accepted0/018ms11536 KiB
2Accepted0/017ms11508 KiB
3Accepted2/217ms11892 KiB
4Accepted3/318ms12152 KiB
5Accepted3/317ms12032 KiB
6Accepted3/317ms12460 KiB
7Accepted3/317ms12440 KiB
8Accepted3/317ms12740 KiB
9Accepted3/317ms12796 KiB
10Accepted3/317ms13016 KiB
11Accepted3/317ms13048 KiB
12Accepted3/317ms13344 KiB
13Accepted3/317ms13336 KiB
14Accepted3/317ms13400 KiB
15Accepted4/417ms13724 KiB
16Accepted4/417ms13668 KiB
17Accepted4/417ms13644 KiB
18Accepted4/417ms13596 KiB
19Accepted4/417ms13708 KiB
20Accepted4/417ms13368 KiB
21Accepted4/417ms13808 KiB
22Accepted4/417ms14124 KiB
23Partially correct1/317ms13848 KiB