Submission #1453239


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 9999999
#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 500
#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 <= r[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 = 0;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 1443 Byte
Status RE
Exec Time 2103 ms
Memory 2176 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
RE × 2
AC × 1
WA × 1
TLE × 11
AC × 5
WA × 2
TLE × 11
RE × 19
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 2176 KB
0_001.txt AC 2 ms 2176 KB
0_002.txt RE 666 ms 2176 KB
0_003.txt RE 96 ms 2176 KB
0_004.txt AC 2 ms 2176 KB
1_005.txt AC 119 ms 2176 KB
1_006.txt WA 222 ms 2176 KB
1_007.txt TLE 2103 ms 2176 KB
1_008.txt TLE 2103 ms 2176 KB
1_009.txt TLE 2103 ms 2176 KB
1_010.txt TLE 2103 ms 2176 KB
1_011.txt TLE 2103 ms 2176 KB
1_012.txt TLE 2103 ms 2176 KB
1_013.txt TLE 2103 ms 2176 KB
1_014.txt TLE 2103 ms 2176 KB
1_015.txt TLE 2103 ms 2176 KB
1_016.txt TLE 2103 ms 2176 KB
1_017.txt TLE 2103 ms 2176 KB
2_018.txt RE 96 ms 2176 KB
2_019.txt WA 2 ms 2176 KB
2_020.txt AC 2 ms 2176 KB
2_021.txt RE 96 ms 2176 KB
2_022.txt RE 97 ms 2176 KB
2_023.txt RE 97 ms 2176 KB
2_024.txt RE 96 ms 2176 KB
2_025.txt RE 97 ms 2176 KB
2_026.txt RE 97 ms 2176 KB
2_027.txt RE 96 ms 2176 KB
2_028.txt RE 97 ms 2176 KB
2_029.txt RE 96 ms 2176 KB
2_030.txt RE 96 ms 2176 KB
2_031.txt RE 96 ms 2176 KB
2_032.txt RE 96 ms 2176 KB
2_033.txt RE 96 ms 2176 KB
2_034.txt RE 96 ms 2176 KB
2_035.txt RE 96 ms 2176 KB
2_036.txt RE 96 ms 2176 KB