Submission #1443440
Source Code Expand
#include<iostream> #include<cstdio> #include<map> using namespace std; map<int ,long long>dp[410]; int n; long long ans=1e18; int l[410],r[410]; int mabs(int x) { if(x<0)return -x;return x; } int main() { scanf("%d",&n); if(n>400) { return 0; } for(int i=1;i<=n;i++) { scanf("%d%d",l+i,r+i); } for(int i=1;i<=n;i++) { int ln=r[i-1]-l[i-1]; for(int j=-800;j<=800;j++) { dp[i][j]=1e18; int cst=mabs(l[i]-j); for(int k=j-ln;k<=j+r[i]-l[i];k++) { if(dp[i-1][k]==1e18)continue; dp[i][j]=min(dp[i][j],dp[i-1][k]+cst); if(i==n)ans=min(ans,dp[i][j]); } } } printf("%lld",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | ASSWECAN |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 672 Byte |
Status | WA |
Exec Time | 2105 ms |
Memory | 43904 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:22:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] 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 | 640 KB |
0_001.txt | AC | 5 ms | 640 KB |
0_002.txt | WA | 5 ms | 896 KB |
0_003.txt | TLE | 2105 ms | 43904 KB |
0_004.txt | AC | 104 ms | 512 KB |
1_005.txt | WA | 320 ms | 40448 KB |
1_006.txt | WA | 316 ms | 40448 KB |
1_007.txt | TLE | 2103 ms | 2304 KB |
1_008.txt | TLE | 2104 ms | 6400 KB |
1_009.txt | TLE | 2104 ms | 7040 KB |
1_010.txt | TLE | 2104 ms | 7424 KB |
1_011.txt | TLE | 2104 ms | 8320 KB |
1_012.txt | TLE | 2104 ms | 7808 KB |
1_013.txt | TLE | 2104 ms | 6656 KB |
1_014.txt | TLE | 2104 ms | 5888 KB |
1_015.txt | TLE | 2104 ms | 7424 KB |
1_016.txt | TLE | 2103 ms | 8448 KB |
1_017.txt | TLE | 2104 ms | 7296 KB |
2_018.txt | WA | 1 ms | 256 KB |
2_019.txt | WA | 1 ms | 256 KB |
2_020.txt | WA | 1 ms | 256 KB |
2_021.txt | WA | 1 ms | 256 KB |
2_022.txt | WA | 1 ms | 256 KB |
2_023.txt | WA | 1 ms | 256 KB |
2_024.txt | WA | 1 ms | 256 KB |
2_025.txt | WA | 1 ms | 256 KB |
2_026.txt | WA | 1 ms | 256 KB |
2_027.txt | WA | 1 ms | 256 KB |
2_028.txt | WA | 1 ms | 256 KB |
2_029.txt | WA | 1 ms | 256 KB |
2_030.txt | WA | 1 ms | 256 KB |
2_031.txt | WA | 1 ms | 256 KB |
2_032.txt | WA | 1 ms | 256 KB |
2_033.txt | WA | 1 ms | 256 KB |
2_034.txt | WA | 1 ms | 256 KB |
2_035.txt | WA | 1 ms | 256 KB |
2_036.txt | WA | 1 ms | 256 KB |