Submission #1294712
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> pii; int N; vector<pii> S; vector<vector<int> > cc; int dp(int n, int l) { int &ret = cc[n][l]; if(ret != -1) return ret; l -= 400; if(n == N - 1) return ret = abs(S[n].first - l); int r = l + S[n].second - S[n].first; ret = 1e9; for(int i = -400; i <= 400; i++) { int nl = i, nr = nl + S[n + 1].second - S[n + 1].first; if(r < nl || nr < l) continue; ret = min(ret, abs(S[n].first - l) + dp(n + 1, nl + 400)); } return ret; } int main() { scanf("%d", &N); S.resize(N); for(int i = 0; i < N; i++) { scanf("%d %d", &S[i].first, &S[i].second); } cc = vector<vector<int> >(N, vector<int>(802, -1)); int ans = 1e9; for(int i = 0; i <= 800; i++) ans = min(ans, dp(0, i)); printf("%d", ans); }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | choikiwon |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 897 Byte |
Status | WA |
Exec Time | 2129 ms |
Memory | 327296 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:27:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:30:50: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d", &S[i].first, &S[i].second); ^
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 | 2 ms | 256 KB |
0_001.txt | AC | 2 ms | 256 KB |
0_002.txt | WA | 4 ms | 256 KB |
0_003.txt | WA | 13 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 241 ms | 1536 KB |
1_006.txt | AC | 242 ms | 1536 KB |
1_007.txt | AC | 1092 ms | 1536 KB |
1_008.txt | AC | 489 ms | 1536 KB |
1_009.txt | AC | 477 ms | 1536 KB |
1_010.txt | AC | 498 ms | 1536 KB |
1_011.txt | AC | 495 ms | 1536 KB |
1_012.txt | AC | 484 ms | 1536 KB |
1_013.txt | AC | 510 ms | 1536 KB |
1_014.txt | AC | 512 ms | 1536 KB |
1_015.txt | AC | 491 ms | 1536 KB |
1_016.txt | AC | 501 ms | 1536 KB |
1_017.txt | AC | 517 ms | 1536 KB |
2_018.txt | TLE | 2124 ms | 325248 KB |
2_019.txt | TLE | 2124 ms | 325248 KB |
2_020.txt | TLE | 2124 ms | 325248 KB |
2_021.txt | TLE | 2124 ms | 325248 KB |
2_022.txt | TLE | 2123 ms | 327296 KB |
2_023.txt | TLE | 2124 ms | 325248 KB |
2_024.txt | TLE | 2127 ms | 325248 KB |
2_025.txt | TLE | 2125 ms | 325248 KB |
2_026.txt | TLE | 2126 ms | 325248 KB |
2_027.txt | TLE | 2123 ms | 327296 KB |
2_028.txt | TLE | 2126 ms | 325248 KB |
2_029.txt | TLE | 2124 ms | 325248 KB |
2_030.txt | TLE | 2125 ms | 325248 KB |
2_031.txt | TLE | 2125 ms | 327296 KB |
2_032.txt | TLE | 2126 ms | 325248 KB |
2_033.txt | TLE | 2124 ms | 325248 KB |
2_034.txt | TLE | 2129 ms | 325248 KB |
2_035.txt | TLE | 2125 ms | 325248 KB |
2_036.txt | TLE | 2124 ms | 327296 KB |