Submission #1795147
Source Code Expand
#include <stdio.h>
#include <stdlib.h>
#define MIN(a,b) ((a)<(b))?(a):(b)
#define MAX(a,b) ((a)>(b))?(a):(b)
int N, Z, W;
int a[2000];
int s[2][2000];
int INF=2000000000;
int searchScore(int teban, int i,int x, int y){
//printf("teban=%d, i=%d, x=%d, y=%d ",teban,i,x,y);
if(i==N)return abs(x-y);
//printf("a");
if(s[teban][i]>=0)return s[teban][i];
//printf("b");
int j;
int ret;
int score;
if(teban){
ret=INF;
for(j=i+1;j<=N;j++){
//printf("c1");
//printf("y%d\n",a[j-1]);
score=searchScore(0,j,x,a[j-1]);
ret=MIN(ret,score);
//printf("d1");
}
}else{
ret=0;
for(j=i+1;j<=N;j++){
//printf("c2");
//printf("x%d\n",a[j-1]);
score=searchScore(1,j,a[j-1],y);
ret=MAX(ret,score);
//printf("d2");
}
}
//printf("ret=%d\n",ret);
return s[teban][i]=ret;
}
int main()
{
scanf("%d %d %d",&N,&Z,&W);
int i,j;
for(i=0;i<N;i++)scanf("%d",&a[i]);
for(i=0;i<2;i++)for(j=0;j<N;j++)s[i][j]=-1;
int ans=searchScore(0,0,Z,W);
printf("%d\n",ans);
return 0;
}
Submission Info
Submission Time
2017-11-21 14:32:18+0900
Task
D - ABS
User
kokubun0293
Language
C (GCC 5.4.1)
Score
500
Code Size
1248 Byte
Status
AC
Exec Time
16 ms
Memory
256 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:46:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d",&N,&Z,&W);
^
./Main.c:48:21: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
for(i=0;i<N;i++)scanf("%d",&a[i]);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
500 / 500
Status
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
0 ms
128 KB
example_1
AC
0 ms
128 KB
example_2
AC
0 ms
128 KB
example_3
AC
0 ms
128 KB
one_0
AC
0 ms
128 KB
one_1
AC
0 ms
128 KB
one_2
AC
0 ms
128 KB
one_3
AC
0 ms
128 KB
one_4
AC
0 ms
128 KB
one_5
AC
0 ms
128 KB
one_6
AC
0 ms
128 KB
one_7
AC
0 ms
128 KB
rand_0
AC
15 ms
256 KB
rand_1
AC
2 ms
256 KB
rand_10
AC
16 ms
256 KB
rand_11
AC
3 ms
256 KB
rand_12
AC
15 ms
256 KB
rand_13
AC
12 ms
256 KB
rand_14
AC
15 ms
256 KB
rand_15
AC
1 ms
128 KB
rand_2
AC
15 ms
256 KB
rand_3
AC
12 ms
256 KB
rand_4
AC
15 ms
256 KB
rand_5
AC
5 ms
256 KB
rand_6
AC
16 ms
256 KB
rand_7
AC
6 ms
256 KB
rand_8
AC
15 ms
256 KB
rand_9
AC
12 ms
256 KB