Submission #1356339
Source Code Expand
#include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> using namespace std; const int maxn = 810; const int INF = 1<<30; int f[maxn][maxn]; int l[maxn], r[maxn]; int main() { //freopen("E.in","r",stdin); //freopen("E.out","w",stdout); int n; scanf("%d",&n); for (int i=1;i<=n;i++) scanf("%d%d",&l[i],&r[i]); for (int i=0;i<maxn;i++) for (int j=0;j<maxn;j++) f[i][j] = INF; for (int i=max(r[1]-l[1],1);i<maxn;i++) f[1][i] = abs(r[1] - i); for (int i=1;i<n;i++) { for (int j=0;j<maxn;j++) { for (int x=-maxn/2;x<maxn/2;x++) { int newl = l[i+1] - x, newr = r[i+1] - x; if (newl <= 0) break; if (newl <= j) f[i+1][newr] = min(f[i+1][newr], f[i][j] + abs(x)); //cout<<i<<" "<<i+1<<" "<<j<<" "<<x<<" "<<newr<<" "<<f[i][j]+abs(x)<<" "<<f[i+1][newr]<<endl; } } } int ans = INF; for (int i=0;i<maxn;i++) ans = min(ans,f[n][i]); printf("%d\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | Gabriel |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 968 Byte |
Status | RE |
Exec Time | 2103 ms |
Memory | 2816 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:18:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:19:50: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (int i=1;i<=n;i++) scanf("%d%d",&l[i],&r[i]); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 4 ms | 2816 KB |
0_001.txt | AC | 4 ms | 2816 KB |
0_002.txt | WA | 5 ms | 2816 KB |
0_003.txt | RE | 100 ms | 2816 KB |
0_004.txt | AC | 3 ms | 2816 KB |
1_005.txt | AC | 312 ms | 2816 KB |
1_006.txt | AC | 312 ms | 2816 KB |
1_007.txt | AC | 232 ms | 2816 KB |
1_008.txt | WA | 321 ms | 2816 KB |
1_009.txt | WA | 323 ms | 2816 KB |
1_010.txt | WA | 316 ms | 2816 KB |
1_011.txt | WA | 317 ms | 2816 KB |
1_012.txt | WA | 319 ms | 2816 KB |
1_013.txt | WA | 314 ms | 2816 KB |
1_014.txt | WA | 313 ms | 2816 KB |
1_015.txt | WA | 319 ms | 2816 KB |
1_016.txt | WA | 319 ms | 2816 KB |
1_017.txt | WA | 315 ms | 2816 KB |
2_018.txt | RE | 612 ms | 2816 KB |
2_019.txt | RE | 582 ms | 2816 KB |
2_020.txt | TLE | 2103 ms | 2816 KB |
2_021.txt | TLE | 2103 ms | 2816 KB |
2_022.txt | TLE | 2103 ms | 2816 KB |
2_023.txt | TLE | 2103 ms | 2816 KB |
2_024.txt | TLE | 2103 ms | 2816 KB |
2_025.txt | TLE | 2103 ms | 2816 KB |
2_026.txt | TLE | 2103 ms | 2816 KB |
2_027.txt | TLE | 2103 ms | 2816 KB |
2_028.txt | TLE | 2103 ms | 2816 KB |
2_029.txt | TLE | 2103 ms | 2816 KB |
2_030.txt | TLE | 2103 ms | 2816 KB |
2_031.txt | TLE | 2103 ms | 2816 KB |
2_032.txt | TLE | 2103 ms | 2816 KB |
2_033.txt | TLE | 2103 ms | 2816 KB |
2_034.txt | TLE | 2103 ms | 2816 KB |
2_035.txt | TLE | 2103 ms | 2816 KB |
2_036.txt | TLE | 2103 ms | 2816 KB |