結果

問題 No.2593 Reorder and Mod 120
ユーザー Atsushi TamuraAtsushi Tamura
提出日時 2023-12-30 22:59:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 2,527 bytes
コンパイル時間 539 ms
コンパイル使用メモリ 12,032 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2023-12-30 22:59:42
合計ジャッジ時間 2,014 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,112 KB
testcase_01 RE -
testcase_02 AC 32 ms
10,112 KB
testcase_03 AC 31 ms
10,112 KB
testcase_04 AC 31 ms
10,112 KB
testcase_05 AC 30 ms
10,112 KB
testcase_06 AC 31 ms
10,112 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

ss = int(input())
a=[i for i in range(120)]
n_str=input()
n_int=int(n_str)
n_str_list=list(n_str)
n_int_list=sorted([int(i) for i in n_str_list]) 


exchange_list_1 = []
exchange_list_10 = []
exchange_list_100 = []

n_div_120 = 0
for i in n_int_list:
    n_div_120 += i
n_div_120 = n_div_120 % 120 


three_list = [n_int_list[0], n_int_list[1], n_int_list[2]]

for _ in range(3):
    n_int_list.pop(0) 

while True: 
    
    three_int = three_list[0]*100 + three_list[1]*10 + three_list[2] 

    x = (120 + n_div_120 - (three_list[0] + three_list[1] + three_list[2]))%120
    
    y = three_int % 120
    
    z = (40*x + y) % 120
    if z in a:
        a.remove(z)

   
    exchange_list_1.append(three_list[2])

    
    for i in range(len(n_str)-3):
        if n_int_list[i]>=three_list[2]:
            n_int_list.insert(i, three_list[2])
            break
    else:
        n_int_list.append(three_list[2])

   
    three_list.pop()
   
    for i in n_int_list:
        if i not in exchange_list_1:
            three_list.append(i) 
            n_int_list.remove(i)
            break 

    else: 
        exchange_list_1.clear()
        exchange_list_10.append(three_list[1])
        
        for i in range(len(n_str)-2):
            if n_int_list[i]>=three_list[1]:
                n_int_list.insert(i, three_list[1])
                break
        else:
            n_int_list.append(three_list[1])
        three_list.pop() 
        for i in n_int_list:
            if i not in exchange_list_10:
                three_list.append(i) 
                n_int_list.remove(i)
                three_list.append(n_int_list[0])
                n_int_list.pop(0)
                break
        
        else: 
            exchange_list_10.clear()
            exchange_list_100.append(three_list[0])
            for i in range(len(n_str)-1):
                if n_int_list[i]>=three_list[0]:
                    n_int_list.insert(i, three_list[0])
                    break
            else:
                n_int_list.append(three_list[0])
            three_list.pop()
            for i in n_int_list:
                if i not in exchange_list_100:
                    three_list.append(i) 
                    n_int_list.remove(i)
                    three_list.append(n_int_list[0])
                    n_int_list.pop(0)
                    three_list.append(n_int_list[0])
                    n_int_list.pop(0)
                    break 
            
            else: 
                print(120 - len(a))
                break
0