Submission #4034724
Source Code Expand
n = int(input()) a = [list(map(int,input().split())) for i in range(n)] dp = [[float("inf")]*(500) for i in range(n+1)] if n > 400: exit() for i in range(500): dp[0][i] = 0 for i in range(1,n+1): m = a[i-1][1] - a[i-1][0] mm = a[i-2][1] - a[i-2][0] for j in range(405): for k in range(405): if (j<= k and k<=j+m) or (k<= j and j <= k+mm) or i == 1: dp[i][j] = min(dp[i][j],dp[i-1][k]+abs(j-a[i-1][0])) ans = float("inf") for i in range(500): ans = min(ans,dp[n][i]) print(ans)
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | rookzeno |
Language | PyPy3 (2.4.0) |
Score | 300 |
Code Size | 523 Byte |
Status | WA |
Exec Time | 1721 ms |
Memory | 444420 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 0 / 700 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt |
Subtask | 0_000, 0_001, 0_004, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 213 ms | 42096 KB |
0_001.txt | AC | 248 ms | 45936 KB |
0_002.txt | WA | 224 ms | 42736 KB |
0_003.txt | WA | 257 ms | 45424 KB |
0_004.txt | AC | 193 ms | 39792 KB |
1_005.txt | AC | 1236 ms | 52188 KB |
1_006.txt | AC | 1201 ms | 51676 KB |
1_007.txt | AC | 1690 ms | 50268 KB |
1_008.txt | AC | 1463 ms | 56540 KB |
1_009.txt | AC | 1449 ms | 56924 KB |
1_010.txt | AC | 1464 ms | 56796 KB |
1_011.txt | AC | 1435 ms | 56628 KB |
1_012.txt | AC | 1403 ms | 56796 KB |
1_013.txt | AC | 1487 ms | 56924 KB |
1_014.txt | AC | 1443 ms | 56156 KB |
1_015.txt | AC | 1439 ms | 56284 KB |
1_016.txt | AC | 1721 ms | 57396 KB |
1_017.txt | AC | 1701 ms | 56156 KB |
2_018.txt | MLE | 1033 ms | 444164 KB |
2_019.txt | MLE | 987 ms | 443908 KB |
2_020.txt | MLE | 1015 ms | 444420 KB |
2_021.txt | MLE | 1024 ms | 443908 KB |
2_022.txt | MLE | 1034 ms | 444420 KB |
2_023.txt | MLE | 1024 ms | 443908 KB |
2_024.txt | MLE | 1018 ms | 443908 KB |
2_025.txt | MLE | 1032 ms | 443908 KB |
2_026.txt | MLE | 1025 ms | 443908 KB |
2_027.txt | MLE | 1051 ms | 443908 KB |
2_028.txt | MLE | 1045 ms | 443908 KB |
2_029.txt | MLE | 1049 ms | 444420 KB |
2_030.txt | MLE | 1054 ms | 444420 KB |
2_031.txt | MLE | 1042 ms | 443908 KB |
2_032.txt | MLE | 1005 ms | 444420 KB |
2_033.txt | MLE | 995 ms | 444420 KB |
2_034.txt | MLE | 1043 ms | 443908 KB |
2_035.txt | MLE | 1064 ms | 443908 KB |
2_036.txt | MLE | 1041 ms | 444420 KB |