Submission #1453274


Source Code Expand

/*
	% D a l a o
          --InterestingLSY
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define pb push_back
#define mp make_pair
#define INF (1e9)
#define LINF (1e18)
#define SINF "%"
#define uint unsigned int
#define msn(a,v) memset(a,v,sizeof(a))
#define ms(a) msn(a,0)
#define NONE -1
#define ll long long
#define uchar unsigned char
#define sint short int
#define usint unsigned sint
using namespace std;
#define MAXN 2000
#define P +MAXN
 
int n;
int l[MAXN],r[MAXN];
int len[MAXN];
 
int mem[MAXN][MAXN P];
int myabs( int x ){
	if( x >= 0 ) return x;
	else return -x;
}
int dp(int pos,int lastl){
	if(pos == n+1) return 0;
	if(mem[pos][lastl P] != -1) return mem[pos][lastl P];
	int ans = INF;
	for(int nowl = lastl-len[pos];nowl <= lastl+len[pos-1];nowl++){
		int nowans = dp(pos+1,nowl) + myabs(l[pos]-nowl);
		if( ans > nowans ){
			ans = nowans;
		}
	}
	mem[pos][lastl P] = ans;
	return ans;
}
int main(){
	//freopen("E.txt","r",stdin);
	msn(mem,-1);
	
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		scanf("%d %d",&l[i],&r[i]);
		len[i] = r[i] - l[i];
	}
	
	int ans = INF;
	for(int i = -MAXN;i <= MAXN;i++){
		int nowans = dp(2,i) + myabs(i-l[1]);
		if( ans > nowans ){
			ans = nowans;
		}
	}
		
	printf("%d\n\n",ans);
	
	return 0;
}

Submission Info

Submission Time
Task E - NarrowRectangles
User interestingLSY
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1454 Byte
Status RE
Exec Time 2103 ms
Memory 31616 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:58:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:60:29: 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
AC × 3
WA × 1
RE × 1
AC × 2
WA × 10
TLE × 1
AC × 6
WA × 12
TLE × 1
RE × 18
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 9 ms 31488 KB
0_001.txt AC 9 ms 31488 KB
0_002.txt WA 10 ms 31488 KB
0_003.txt RE 107 ms 31488 KB
0_004.txt AC 9 ms 31488 KB
1_005.txt AC 35 ms 31488 KB
1_006.txt AC 35 ms 31488 KB
1_007.txt TLE 2103 ms 31488 KB
1_008.txt WA 1341 ms 31488 KB
1_009.txt WA 1278 ms 31488 KB
1_010.txt WA 1395 ms 31488 KB
1_011.txt WA 1382 ms 31488 KB
1_012.txt WA 1315 ms 31488 KB
1_013.txt WA 1462 ms 31488 KB
1_014.txt WA 1474 ms 31488 KB
1_015.txt WA 1357 ms 31488 KB
1_016.txt WA 1426 ms 31616 KB
1_017.txt WA 1507 ms 31488 KB
2_018.txt RE 106 ms 31488 KB
2_019.txt WA 10 ms 31488 KB
2_020.txt AC 10 ms 31488 KB
2_021.txt RE 105 ms 31488 KB
2_022.txt RE 106 ms 31488 KB
2_023.txt RE 105 ms 31488 KB
2_024.txt RE 105 ms 31488 KB
2_025.txt RE 107 ms 31488 KB
2_026.txt RE 106 ms 31488 KB
2_027.txt RE 107 ms 31488 KB
2_028.txt RE 106 ms 31488 KB
2_029.txt RE 107 ms 31488 KB
2_030.txt RE 105 ms 31488 KB
2_031.txt RE 104 ms 31488 KB
2_032.txt RE 104 ms 31488 KB
2_033.txt RE 105 ms 31488 KB
2_034.txt RE 106 ms 31488 KB
2_035.txt RE 104 ms 31488 KB
2_036.txt RE 105 ms 31488 KB