結果
問題 | No.1028 闇討ち |
ユーザー | Coki628 |
提出日時 | 2020-08-04 16:21:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,387 bytes |
コンパイル時間 | 355 ms |
コンパイル使用メモリ | 11,160 KB |
実行使用メモリ | 80,904 KB |
最終ジャッジ日時 | 2023-10-12 19:44:20 |
合計ジャッジ時間 | 25,211 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,668 KB |
testcase_01 | AC | 16 ms
8,648 KB |
testcase_02 | AC | 16 ms
8,720 KB |
testcase_03 | AC | 17 ms
8,576 KB |
testcase_04 | AC | 17 ms
8,596 KB |
testcase_05 | AC | 19 ms
8,548 KB |
testcase_06 | AC | 21 ms
8,792 KB |
testcase_07 | AC | 17 ms
8,688 KB |
testcase_08 | AC | 18 ms
8,680 KB |
testcase_09 | AC | 104 ms
10,936 KB |
testcase_10 | AC | 149 ms
12,116 KB |
testcase_11 | AC | 569 ms
23,956 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | AC | 1,277 ms
44,516 KB |
testcase_15 | AC | 412 ms
19,640 KB |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
ソースコード
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 19 MOD = 10 ** 9 + 7 EPS = 10 ** -10 N = INT() imos1 = list2d(N, N+1, 0) imos2 = list2d(N, N+1, 0) fixed = [0] * N ll = 0 rr = N for i in range(N): for j, a in enumerate([a-1 for a in LIST()]): lr = max(i-j, 0) rl = min(i+j+1, N) imos1[a][ll] += 1 imos1[a][lr] -= 1 imos2[a][rl] += 1 imos2[a][rr] -= 1 fixed[a] += j for i in range(N): imos1[i] = list(accumulate(imos1[i])) imos2[i] = list(accumulate(imos2[i])) imos1[i] = list(accumulate(imos1[i][::-1]))[::-1] imos2[i] = list(accumulate(imos2[i])) ans = 0 for a in range(N): mn = INF for i in range(N): mn = min(mn, imos1[a][i] + imos2[a][i] + fixed[a]) ans += mn print(ans)