Submission #16008230


Source Code Expand

Copy
import numpy as np
import sys
input = sys.stdin.readline


def main():
    h, w, k = map(int, input().split())
    values = np.zeros((h, w), dtype=np.int64)
    items = np.array([list(map(int, input().split())) for _ in range(k)])
    ys, xs, vs = items[:, 0] - 1, items[:, 1] - 1, items[:, 2]
    values[ys, xs] = vs

    DP = np.zeros(w + 1, dtype=np.int64)
    for line in values:
        DP[1:] += line
        DP = np.maximum.accumulate(DP)
        for _ in range(2):
            DP[1:] = np.maximum(DP[:-1] + line, DP[1:])
            DP = np.maximum.accumulate(DP)
    print(DP[-1])


if __name__ == "__main__":
    main()

Submission Info

Submission Time
Task E - Picking Goods
User parsely
Language Python (3.8.2)
Score 500
Code Size 654 Byte
Status AC
Exec Time 536 ms
Memory 105332 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 37
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 112 ms 26788 KB
02.txt AC 112 ms 27068 KB
03.txt AC 113 ms 27104 KB
04.txt AC 114 ms 27272 KB
05.txt AC 115 ms 27144 KB
06.txt AC 114 ms 27104 KB
07.txt AC 116 ms 27196 KB
08.txt AC 117 ms 27180 KB
09.txt AC 118 ms 27428 KB
10.txt AC 106 ms 27192 KB
11.txt AC 112 ms 27052 KB
12.txt AC 533 ms 105332 KB
13.txt AC 530 ms 105064 KB
14.txt AC 536 ms 104840 KB
15.txt AC 528 ms 104776 KB
16.txt AC 527 ms 104976 KB
17.txt AC 211 ms 27216 KB
18.txt AC 231 ms 37780 KB
19.txt AC 222 ms 28520 KB
20.txt AC 225 ms 36980 KB
21.txt AC 508 ms 73656 KB
22.txt AC 497 ms 67396 KB
23.txt AC 194 ms 36064 KB
24.txt AC 197 ms 37580 KB
25.txt AC 136 ms 27008 KB
26.txt AC 111 ms 27636 KB
27.txt AC 321 ms 52632 KB
28.txt AC 286 ms 49712 KB
29.txt AC 344 ms 98636 KB
30.txt AC 495 ms 103600 KB
31.txt AC 294 ms 93404 KB
32.txt AC 289 ms 91868 KB
33.txt AC 338 ms 97952 KB
34.txt AC 383 ms 101000 KB
s1.txt AC 116 ms 26944 KB
s2.txt AC 116 ms 27000 KB
s3.txt AC 118 ms 27072 KB