結果
問題 | No.2473 Fraises dans une boîte |
ユーザー | 👑 rin204 |
提出日時 | 2023-07-30 15:55:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,444 ms / 4,000 ms |
コード長 | 1,288 bytes |
コンパイル時間 | 255 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 80,660 KB |
最終ジャッジ日時 | 2024-11-07 08:39:59 |
合計ジャッジ時間 | 33,432 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,480 KB |
testcase_01 | AC | 42 ms
52,736 KB |
testcase_02 | AC | 43 ms
52,352 KB |
testcase_03 | AC | 42 ms
52,096 KB |
testcase_04 | AC | 42 ms
52,224 KB |
testcase_05 | AC | 42 ms
52,480 KB |
testcase_06 | AC | 85 ms
72,704 KB |
testcase_07 | AC | 87 ms
75,136 KB |
testcase_08 | AC | 95 ms
76,544 KB |
testcase_09 | AC | 97 ms
76,672 KB |
testcase_10 | AC | 97 ms
76,672 KB |
testcase_11 | AC | 42 ms
52,352 KB |
testcase_12 | AC | 42 ms
52,736 KB |
testcase_13 | AC | 91 ms
76,288 KB |
testcase_14 | AC | 91 ms
76,544 KB |
testcase_15 | AC | 90 ms
76,672 KB |
testcase_16 | AC | 90 ms
76,800 KB |
testcase_17 | AC | 94 ms
76,672 KB |
testcase_18 | AC | 91 ms
76,544 KB |
testcase_19 | AC | 92 ms
76,672 KB |
testcase_20 | AC | 94 ms
76,672 KB |
testcase_21 | AC | 91 ms
76,672 KB |
testcase_22 | AC | 101 ms
76,544 KB |
testcase_23 | AC | 99 ms
76,544 KB |
testcase_24 | AC | 99 ms
75,980 KB |
testcase_25 | AC | 96 ms
76,032 KB |
testcase_26 | AC | 98 ms
76,288 KB |
testcase_27 | AC | 99 ms
76,464 KB |
testcase_28 | AC | 102 ms
76,424 KB |
testcase_29 | AC | 98 ms
76,108 KB |
testcase_30 | AC | 96 ms
76,544 KB |
testcase_31 | AC | 97 ms
76,308 KB |
testcase_32 | AC | 98 ms
76,416 KB |
testcase_33 | AC | 97 ms
76,340 KB |
testcase_34 | AC | 94 ms
76,160 KB |
testcase_35 | AC | 98 ms
76,416 KB |
testcase_36 | AC | 95 ms
76,416 KB |
testcase_37 | AC | 96 ms
76,672 KB |
testcase_38 | AC | 94 ms
76,416 KB |
testcase_39 | AC | 100 ms
76,440 KB |
testcase_40 | AC | 168 ms
77,560 KB |
testcase_41 | AC | 178 ms
77,740 KB |
testcase_42 | AC | 137 ms
76,704 KB |
testcase_43 | AC | 482 ms
78,996 KB |
testcase_44 | AC | 487 ms
78,396 KB |
testcase_45 | AC | 450 ms
78,716 KB |
testcase_46 | AC | 869 ms
79,452 KB |
testcase_47 | AC | 840 ms
79,224 KB |
testcase_48 | AC | 840 ms
80,132 KB |
testcase_49 | AC | 1,319 ms
80,640 KB |
testcase_50 | AC | 989 ms
80,536 KB |
testcase_51 | AC | 1,382 ms
80,116 KB |
testcase_52 | AC | 1,277 ms
80,660 KB |
testcase_53 | AC | 1,321 ms
80,116 KB |
testcase_54 | AC | 1,197 ms
80,188 KB |
testcase_55 | AC | 1,317 ms
80,504 KB |
testcase_56 | AC | 1,017 ms
80,548 KB |
testcase_57 | AC | 1,231 ms
80,056 KB |
testcase_58 | AC | 949 ms
79,876 KB |
testcase_59 | AC | 945 ms
80,256 KB |
testcase_60 | AC | 1,444 ms
79,964 KB |
testcase_61 | AC | 1,089 ms
80,512 KB |
testcase_62 | AC | 1,235 ms
80,368 KB |
testcase_63 | AC | 1,011 ms
80,272 KB |
testcase_64 | AC | 982 ms
80,008 KB |
testcase_65 | AC | 1,413 ms
80,088 KB |
testcase_66 | AC | 955 ms
80,380 KB |
testcase_67 | AC | 830 ms
79,620 KB |
testcase_68 | AC | 1,092 ms
79,620 KB |
ソースコード
h, w = map(int, input().split()) S = [list(map(int, input().split())) for _ in range(h)] cum = [[0] * (w + 1) for _ in range(h + 1)] for i in range(h): for j in range(w): cum[i + 1][j + 1] = cum[i + 1][j] + cum[i][j + 1] - cum[i][j] + S[i][j] def f(i0, i1, j0, j1): return cum[i1][j1] - cum[i0][j1] - cum[i1][j0] + cum[i0][j0] zz = [w] * (h + 1) for i in range(h + 1): while zz[i] > 0 and f(i, h, zz[i] - 1, w) == 0: zz[i] -= 1 dp = [[1 << 30] * (w + 1) for _ in range(h + 1)] dp[h][w] = 0 for i in range(h, -1, -1): for j in range(w, -1, -1): if i != h and f(i, i + 1, j, w) == 0: dp[i][j] = min(dp[i][j], dp[i + 1][j]) if j != w and f(i, h, j, j + 1) == 0: dp[i][j] = min(dp[i][j], dp[i][j + 1]) row = [0] * (h + 1) col = [0] * (w + 1) for i2 in range(i, h): row[i2 + 1] = row[i2] + int(f(i2, i2 + 1, j, w) > 0) for j2 in range(j, w): col[j2 + 1] = col[j2] + int(f(i, h, j2, j2 + 1) > 0) for i2 in range(i + 1, h + 1): j2 = max(j + 1, zz[i2]) if j2 > w: continue tmp = dp[i2][j] + dp[i][j2] + (row[i2] * col[j2] - f(i, i2, j, j2)) dp[i][j] = min(dp[i][j], tmp) print(dp[0][0])