Submission #2670162


Source Code Expand

#include<bits/stdc++.h>
#define N 20005
using namespace std;
int f[N][2],n,Z,W,a[N];bool vis[N][2];
int dp(int last,int who){
	if (vis[last][who]) return f[last][who];
	int ret=abs(a[n]-a[last]);
	vis[last][who]=1;
	if (!who){
		for (int i=last+1;i<n;i++) ret=max(ret,abs(dp(i,!who)));
		return f[last][who]=ret;
	}
	if (who){
		for (int i=last+1;i<n;i++) ret=min(ret,abs(dp(i,!who)));
		return f[last][who]=ret;
	}
}
int main(){
	scanf("%d%d%d",&n,&Z,&W);a[0]=W;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%d\n",abs(dp(0,0)));
	return 0;
}

Submission Info

Submission Time
Task D - ABS
User trans
Language C++14 (GCC 5.4.1)
Score 500
Code Size 571 Byte
Status AC
Exec Time 16 ms
Memory 512 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&Z,&W);a[0]=W;
                          ^
./Main.cpp:20:42: 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",&a[i]);
                                          ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 4
AC × 28
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All example_0, example_1, example_2, example_3, one_0, one_1, one_2, one_3, one_4, one_5, one_6, one_7, rand_0, rand_1, rand_10, rand_11, rand_12, rand_13, rand_14, rand_15, rand_2, rand_3, rand_4, rand_5, rand_6, rand_7, rand_8, rand_9
Case Name Status Exec Time Memory
example_0 AC 1 ms 256 KB
example_1 AC 1 ms 256 KB
example_2 AC 1 ms 256 KB
example_3 AC 1 ms 256 KB
one_0 AC 1 ms 256 KB
one_1 AC 1 ms 256 KB
one_2 AC 1 ms 256 KB
one_3 AC 1 ms 256 KB
one_4 AC 1 ms 256 KB
one_5 AC 1 ms 256 KB
one_6 AC 1 ms 256 KB
one_7 AC 1 ms 256 KB
rand_0 AC 16 ms 384 KB
rand_1 AC 3 ms 256 KB
rand_10 AC 16 ms 384 KB
rand_11 AC 4 ms 256 KB
rand_12 AC 16 ms 384 KB
rand_13 AC 12 ms 384 KB
rand_14 AC 16 ms 384 KB
rand_15 AC 1 ms 256 KB
rand_2 AC 16 ms 384 KB
rand_3 AC 12 ms 384 KB
rand_4 AC 16 ms 384 KB
rand_5 AC 6 ms 256 KB
rand_6 AC 16 ms 512 KB
rand_7 AC 7 ms 384 KB
rand_8 AC 16 ms 384 KB
rand_9 AC 12 ms 384 KB