Submission #1294706
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; 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 = 0; 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)); } 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>(402, -1)); int ans = 1e9; for(int i = 0; i <= 400; 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 | 873 Byte |
Status | WA |
Exec Time | 2116 ms |
Memory | 171008 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:26:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &N); ^ ./Main.cpp:29: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 | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | WA | 2 ms | 256 KB |
0_003.txt | WA | 4 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 67 ms | 896 KB |
1_006.txt | AC | 67 ms | 896 KB |
1_007.txt | AC | 343 ms | 896 KB |
1_008.txt | AC | 173 ms | 896 KB |
1_009.txt | AC | 168 ms | 896 KB |
1_010.txt | AC | 175 ms | 896 KB |
1_011.txt | AC | 175 ms | 896 KB |
1_012.txt | AC | 171 ms | 896 KB |
1_013.txt | AC | 179 ms | 896 KB |
1_014.txt | AC | 182 ms | 896 KB |
1_015.txt | AC | 173 ms | 896 KB |
1_016.txt | AC | 177 ms | 896 KB |
1_017.txt | AC | 184 ms | 896 KB |
2_018.txt | TLE | 2114 ms | 168960 KB |
2_019.txt | TLE | 2113 ms | 171008 KB |
2_020.txt | TLE | 2114 ms | 168960 KB |
2_021.txt | TLE | 2114 ms | 168960 KB |
2_022.txt | TLE | 2114 ms | 168960 KB |
2_023.txt | TLE | 2113 ms | 171008 KB |
2_024.txt | TLE | 2116 ms | 168960 KB |
2_025.txt | TLE | 2114 ms | 168960 KB |
2_026.txt | TLE | 2114 ms | 168960 KB |
2_027.txt | TLE | 2114 ms | 168960 KB |
2_028.txt | TLE | 2114 ms | 168960 KB |
2_029.txt | TLE | 2114 ms | 168960 KB |
2_030.txt | TLE | 2114 ms | 168960 KB |
2_031.txt | TLE | 2114 ms | 168960 KB |
2_032.txt | TLE | 2113 ms | 171008 KB |
2_033.txt | TLE | 2114 ms | 168960 KB |
2_034.txt | TLE | 2114 ms | 168960 KB |
2_035.txt | TLE | 2114 ms | 168960 KB |
2_036.txt | TLE | 2113 ms | 168960 KB |