結果

問題 No.1007 コイン集め
ユーザー hedwig100hedwig100
提出日時 2020-04-06 14:03:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,213 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,044 KB
実行使用メモリ 19,292 KB
最終ジャッジ日時 2023-09-20 10:28:20
合計ジャッジ時間 2,624 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,188 KB
testcase_01 AC 15 ms
8,296 KB
testcase_02 AC 15 ms
8,216 KB
testcase_03 AC 15 ms
8,180 KB
testcase_04 AC 15 ms
8,224 KB
testcase_05 AC 16 ms
8,344 KB
testcase_06 AC 16 ms
8,188 KB
testcase_07 WA -
testcase_08 AC 15 ms
7,784 KB
testcase_09 AC 15 ms
8,156 KB
testcase_10 AC 15 ms
8,340 KB
testcase_11 AC 16 ms
7,932 KB
testcase_12 AC 54 ms
19,212 KB
testcase_13 AC 52 ms
19,156 KB
testcase_14 AC 52 ms
19,292 KB
testcase_15 WA -
testcase_16 AC 33 ms
10,628 KB
testcase_17 AC 32 ms
10,784 KB
testcase_18 AC 54 ms
18,964 KB
testcase_19 AC 47 ms
18,928 KB
testcase_20 AC 54 ms
18,916 KB
testcase_21 AC 50 ms
18,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    k -= 1

    if a[k] == 0:
        print(0)
        return 
    
    if a[k] == 1:
        tmp1 = 0
        for i in range(k + 1,n):
            if a[i] > 1:
                tmp1 += a[i]
            else:
                tmp1 += 1
                break
        
        tmp2 = 0
        for i in range(k - 1,-1,-1):
            if a[i] > 1:
                tmp2 += a[i]
            else:
                tmp2 += 1
                break
        
        ans = max(tmp1,tmp2) + 1
        print(ans)
        return
    
    if a[k] > 1:
        tmp1 = 0
        for i in range(k + 1,n):
            if a[i] > 1:
                tmp1 += a[i]
            else:
                tmp1 += 1
                break
        
        tmp2 = 0
        for i in range(k - 1,-1,-1):
            if a[i] > 1:
                tmp2 += a[i]
            else:
                tmp2 += 1
                break
        
        ans = tmp1 + tmp2 + a[k]
        print(ans)
        return
            
if __name__ =='__main__':
    main()  
0