結果

問題 No.2100 [Cherry Alpha C] Two-way Steps
ユーザー tailstails
提出日時 2022-10-17 10:02:57
言語 cLay
(20240104-1)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 2,620 ms
コンパイル使用メモリ 162,448 KB
実行使用メモリ 12,720 KB
最終ジャッジ日時 2023-09-10 09:59:14
合計ジャッジ時間 9,019 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,420 KB
testcase_01 AC 3 ms
7,568 KB
testcase_02 AC 2 ms
7,676 KB
testcase_03 AC 3 ms
7,472 KB
testcase_04 AC 19 ms
12,232 KB
testcase_05 AC 16 ms
11,636 KB
testcase_06 AC 5 ms
8,092 KB
testcase_07 AC 6 ms
8,244 KB
testcase_08 AC 20 ms
12,504 KB
testcase_09 AC 17 ms
11,468 KB
testcase_10 AC 11 ms
8,768 KB
testcase_11 AC 14 ms
11,924 KB
testcase_12 AC 12 ms
9,156 KB
testcase_13 AC 13 ms
11,892 KB
testcase_14 AC 12 ms
8,960 KB
testcase_15 AC 14 ms
11,860 KB
testcase_16 AC 13 ms
9,136 KB
testcase_17 AC 9 ms
11,712 KB
testcase_18 AC 13 ms
12,172 KB
testcase_19 AC 22 ms
12,296 KB
testcase_20 AC 7 ms
8,456 KB
testcase_21 AC 12 ms
9,268 KB
testcase_22 AC 12 ms
9,064 KB
testcase_23 AC 17 ms
12,068 KB
testcase_24 AC 23 ms
12,572 KB
testcase_25 AC 23 ms
12,576 KB
testcase_26 AC 23 ms
12,528 KB
testcase_27 AC 24 ms
12,544 KB
testcase_28 AC 24 ms
12,524 KB
testcase_29 AC 23 ms
12,584 KB
testcase_30 AC 23 ms
12,632 KB
testcase_31 AC 24 ms
12,632 KB
testcase_32 AC 23 ms
12,720 KB
testcase_33 AC 23 ms
12,660 KB
testcase_34 AC 16 ms
11,168 KB
testcase_35 AC 15 ms
11,120 KB
testcase_36 AC 15 ms
11,112 KB
testcase_37 AC 14 ms
11,132 KB
testcase_38 AC 16 ms
11,256 KB
testcase_39 AC 12 ms
8,972 KB
testcase_40 AC 12 ms
9,020 KB
testcase_41 AC 13 ms
9,072 KB
testcase_42 AC 12 ms
9,136 KB
testcase_43 AC 12 ms
9,028 KB
testcase_44 AC 11 ms
12,432 KB
testcase_45 AC 10 ms
12,484 KB
testcase_46 AC 11 ms
12,428 KB
testcase_47 AC 10 ms
12,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll n,m,h[1d5];
int x[2d5],y[];
graph g;
ll d[1d5][2];

void f(int i,bool dir){
	// morau dp j->i
	d[i][0]=-1;
	d[i][1]=-1;
	rep[g.edge[i]](j,g.es[i]){
		if((j<i)==dir){
			if(h[j]>h[i]){
				// kudari
				if(d[j][1]>=0){
					d[i][0]>?=d[j][1];
					d[i][1]>?=d[j][1];
				}
			}else{
				// nobori
				if(d[j][0]>=0){
					d[i][1]>?=d[j][0]+(h[i]-h[j]);
				}
			}
		}
	}
}

{
	rd(n,m,h(n));
	rd((x--,y--)(m));
	g.setEdge(n,m,x,y);

	// tarou kun
	d[0][0]=0;
	d[0][1]=0;
	rep(i,1,n){
		f(i,true);
	}
	wt(d[n-1][1]);
	
	// jirou kun
	d[n-1][0]=0;
	d[n-1][1]=0;
	rrep(i,n-1){
		f(i,false);
	}
	wt(d[0][1]);
}
0