結果

問題 No.833 かっこいい電車
ユーザー kamomekamome
提出日時 2019-07-02 01:45:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,091 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 29,140 KB
最終ジャッジ日時 2023-09-14 23:25:29
合計ジャッジ時間 7,795 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 16 ms
7,860 KB
testcase_02 AC 16 ms
7,812 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 15 ms
7,884 KB
testcase_05 AC 16 ms
7,876 KB
testcase_06 AC 16 ms
7,844 KB
testcase_07 AC 16 ms
7,840 KB
testcase_08 AC 16 ms
7,824 KB
testcase_09 AC 16 ms
7,780 KB
testcase_10 AC 378 ms
19,268 KB
testcase_11 AC 471 ms
24,872 KB
testcase_12 AC 157 ms
14,776 KB
testcase_13 AC 132 ms
10,776 KB
testcase_14 AC 364 ms
25,144 KB
testcase_15 AC 189 ms
18,024 KB
testcase_16 AC 125 ms
21,344 KB
testcase_17 AC 183 ms
9,392 KB
testcase_18 AC 466 ms
19,964 KB
testcase_19 AC 128 ms
19,880 KB
testcase_20 AC 41 ms
12,064 KB
testcase_21 AC 442 ms
13,836 KB
testcase_22 AC 223 ms
26,892 KB
testcase_23 AC 150 ms
20,444 KB
testcase_24 AC 216 ms
25,640 KB
testcase_25 AC 458 ms
18,220 KB
testcase_26 AC 157 ms
21,588 KB
testcase_27 AC 308 ms
18,996 KB
testcase_28 AC 257 ms
13,280 KB
testcase_29 AC 276 ms
16,820 KB
testcase_30 AC 364 ms
29,140 KB
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3
class train:
    def __init__ (self,c):
        self.connected=False
        self.cool=c
    def remodel(self):
        self.cool=self.cool+1
    def connect (self):
        self.connected=True
    def disconnect (self):
        self.connected=False
N,Q=input().split()
trains=[]
for t in input().split():
    trains.append(train(int(t)))

for i in range(int(Q)):
    q,x=input().split()
    x=int(x)
    if q=="1":
        trains[x-1].connect()
    elif q=="2":
        trains[x-1].disconnect()
    elif q=="3":
        trains[x-1].remodel()
    elif q=="4":
        def cnct_max(N):
            if N+1==len(trains):
                return N
            if trains[N].connected:
                return cnct_max(N+1)
            else:
                return N
        def cnct_min(N):
            if N==0:
                return 0
            if trains[N-1].connected:
                return cnct_min(N-1)
            else:
                return N
        s=0
        for i in range(cnct_min(x-1),cnct_max(x-1)+1):
           s=s+trains[i].cool
        print(s)
        

0