結果

問題 No.1028 闇討ち
ユーザー konchanksukonchanksu
提出日時 2020-04-20 20:02:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 805 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 43,392 KB
最終ジャッジ日時 2024-04-16 00:53:18
合計ジャッジ時間 23,485 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
11,008 KB
testcase_01 AC 35 ms
11,008 KB
testcase_02 AC 39 ms
11,008 KB
testcase_03 AC 34 ms
10,880 KB
testcase_04 AC 33 ms
10,880 KB
testcase_05 AC 38 ms
11,008 KB
testcase_06 AC 41 ms
11,136 KB
testcase_07 AC 35 ms
11,008 KB
testcase_08 AC 37 ms
11,008 KB
testcase_09 AC 109 ms
11,264 KB
testcase_10 AC 149 ms
11,648 KB
testcase_11 AC 534 ms
16,640 KB
testcase_12 TLE -
testcase_13 TLE -
testcase_14 AC 1,201 ms
25,728 KB
testcase_15 AC 398 ms
14,464 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from copy import deepcopy, copy
# imosじゃない

n = int(input())

a = [list(map(int, input().split())) for i in range(n)]
ans = [0 for i in range(n)]

imo = [0 for i in range(n)]
tmp = [0 for i in range(n)]

for i in range(n):
    for j in range(n):
        imo[a[i][j] - 1] += max(i, j)
        if i >= j:
            tmp[a[i][j] - 1] -= 1

ans = copy(imo)

# print(tmp)
for i in range(1, n):
    for j in range(n):
        if j - i + 1 == 0:
            tmp[a[i - 1][0] - 1] += 2

        elif j - i + 1 < 0:
            tmp[a[j][abs(j - i + 1)] - 1] += 1

        else:
            tmp[a[j][abs(j - i + 1)] - 1] += 1
            
    # print(tmp)
    for j in range(n):
        imo[j] = tmp[j] + imo[j]
    # print(imo)
    for j in range(n):
        ans[j] = min(imo[j], ans[j])  

print(sum(ans))
0