Submission #1443964
Source Code Expand
#include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include <cmath> #include <queue> using namespace std; const int N=100001; int n,minn; struct node { int l; int r; int len; }p[N]; int dp[401][401];//第i层的左端点在j int main() { int i,j,k; cin>>n; for(i=1;i<=n;i++) { scanf("%d %d",&p[i].l,&p[i].r); p[i].len=(p[i].r-p[i].l); } memset(dp,0x7f,sizeof(dp)); minn=dp[0][0]; for(i=1;i<=n;i++) dp[1][i]=abs(p[1].l-i); for(i=2;i<=n;i++) { for(j=1;j<=400;j++) for(k=1;k<=400;k++) { if((j>k+p[i-1].len)||(k>j+p[i].len)) continue; dp[i][j]=min(dp[i][j],dp[i-1][k]+abs(j-p[i].l)); } } for(i=1;i<=400;i++) minn=min(minn,dp[n][i]); cout<<minn; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | shanyuqiang |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 944 Byte |
Status | RE |
Exec Time | 596 ms |
Memory | 2048 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:25:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&p[i].l,&p[i].r); ^
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 | 896 KB |
0_001.txt | AC | 2 ms | 896 KB |
0_002.txt | WA | 2 ms | 896 KB |
0_003.txt | WA | 3 ms | 896 KB |
0_004.txt | AC | 1 ms | 896 KB |
1_005.txt | AC | 67 ms | 896 KB |
1_006.txt | AC | 67 ms | 896 KB |
1_007.txt | AC | 167 ms | 896 KB |
1_008.txt | AC | 105 ms | 896 KB |
1_009.txt | AC | 103 ms | 896 KB |
1_010.txt | AC | 106 ms | 896 KB |
1_011.txt | AC | 106 ms | 896 KB |
1_012.txt | AC | 104 ms | 896 KB |
1_013.txt | AC | 107 ms | 896 KB |
1_014.txt | AC | 108 ms | 896 KB |
1_015.txt | AC | 105 ms | 896 KB |
1_016.txt | AC | 106 ms | 896 KB |
1_017.txt | AC | 109 ms | 896 KB |
2_018.txt | RE | 331 ms | 2048 KB |
2_019.txt | RE | 302 ms | 2048 KB |
2_020.txt | RE | 526 ms | 2048 KB |
2_021.txt | RE | 596 ms | 2048 KB |
2_022.txt | RE | 591 ms | 2048 KB |
2_023.txt | RE | 592 ms | 2048 KB |
2_024.txt | RE | 593 ms | 2048 KB |
2_025.txt | RE | 592 ms | 2048 KB |
2_026.txt | RE | 592 ms | 2048 KB |
2_027.txt | RE | 593 ms | 2048 KB |
2_028.txt | RE | 592 ms | 2048 KB |
2_029.txt | RE | 592 ms | 2048 KB |
2_030.txt | RE | 593 ms | 2048 KB |
2_031.txt | RE | 320 ms | 2048 KB |
2_032.txt | RE | 367 ms | 2048 KB |
2_033.txt | RE | 382 ms | 2048 KB |
2_034.txt | RE | 592 ms | 2048 KB |
2_035.txt | RE | 596 ms | 2048 KB |
2_036.txt | RE | 591 ms | 2048 KB |