AtCoder Regular Contest 070

Submission #1356344

Source codeソースコード

#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 && newr >= j-r[i]+l[i]) 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

Task問題 E - NarrowRectangles
User nameユーザ名 Gabriel
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 RE
Score得点 300
Source lengthソースコード長 991 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./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]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_000.txt,0_001.txt,0_002.txt,0_003.txt,0_004.txt
Subtask 300 / 300 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 / 700 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_000.txt AC 3 ms 2816 KB
0_001.txt AC 3 ms 2816 KB
0_002.txt WA
0_003.txt RE
0_004.txt AC 3 ms 2816 KB
1_005.txt AC 238 ms 2816 KB
1_006.txt AC 237 ms 2816 KB
1_007.txt AC 264 ms 2816 KB
1_008.txt AC 286 ms 2816 KB
1_009.txt AC 286 ms 2816 KB
1_010.txt AC 282 ms 2816 KB
1_011.txt AC 284 ms 2816 KB
1_012.txt AC 283 ms 2816 KB
1_013.txt AC 282 ms 2944 KB
1_014.txt AC 282 ms 2816 KB
1_015.txt AC 284 ms 2816 KB
1_016.txt AC 286 ms 2816 KB
1_017.txt AC 285 ms 2816 KB
2_018.txt RE
2_019.txt RE
2_020.txt TLE
2_021.txt TLE
2_022.txt TLE
2_023.txt TLE
2_024.txt TLE
2_025.txt TLE
2_026.txt TLE
2_027.txt TLE
2_028.txt TLE
2_029.txt TLE
2_030.txt TLE
2_031.txt TLE
2_032.txt TLE
2_033.txt TLE
2_034.txt TLE
2_035.txt TLE
2_036.txt TLE