結果

問題 No.2100 [Cherry Alpha C] Two-way Steps
ユーザー tailstails
提出日時 2022-10-14 22:49:06
言語 cLay
(20240104-1)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 3,659 ms
コンパイル使用メモリ 163,400 KB
実行使用メモリ 11,032 KB
最終ジャッジ日時 2023-09-08 23:09:59
合計ジャッジ時間 6,749 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 18 ms
9,992 KB
testcase_05 AC 15 ms
9,328 KB
testcase_06 AC 4 ms
4,536 KB
testcase_07 AC 5 ms
4,820 KB
testcase_08 AC 18 ms
10,424 KB
testcase_09 AC 14 ms
9,108 KB
testcase_10 AC 10 ms
5,952 KB
testcase_11 AC 13 ms
9,620 KB
testcase_12 AC 11 ms
8,732 KB
testcase_13 AC 12 ms
9,604 KB
testcase_14 AC 11 ms
6,220 KB
testcase_15 AC 12 ms
9,564 KB
testcase_16 AC 11 ms
6,488 KB
testcase_17 AC 8 ms
9,184 KB
testcase_18 AC 12 ms
9,648 KB
testcase_19 AC 21 ms
10,560 KB
testcase_20 AC 6 ms
5,224 KB
testcase_21 AC 11 ms
8,732 KB
testcase_22 AC 11 ms
6,196 KB
testcase_23 AC 16 ms
10,068 KB
testcase_24 AC 22 ms
10,956 KB
testcase_25 AC 22 ms
11,000 KB
testcase_26 AC 22 ms
10,912 KB
testcase_27 AC 23 ms
10,944 KB
testcase_28 AC 22 ms
10,948 KB
testcase_29 AC 23 ms
11,032 KB
testcase_30 AC 22 ms
10,832 KB
testcase_31 AC 22 ms
10,776 KB
testcase_32 AC 22 ms
10,828 KB
testcase_33 AC 22 ms
11,000 KB
testcase_34 AC 15 ms
8,872 KB
testcase_35 AC 14 ms
8,836 KB
testcase_36 AC 14 ms
8,684 KB
testcase_37 AC 13 ms
8,564 KB
testcase_38 AC 15 ms
8,800 KB
testcase_39 AC 11 ms
8,468 KB
testcase_40 AC 11 ms
8,672 KB
testcase_41 AC 12 ms
8,668 KB
testcase_42 AC 11 ms
8,624 KB
testcase_43 AC 11 ms
8,468 KB
testcase_44 AC 11 ms
10,552 KB
testcase_45 AC 10 ms
10,520 KB
testcase_46 AC 10 ms
10,524 KB
testcase_47 AC 10 ms
10,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

ll@n,@m,@h[n];
int x[m],y[m];
rd((x--,y--)(m));
graph g;
g.setEdge(n,m,x,y);
ll d[n][2];

// tarou kun
d[0][0]=0;
d[0][1]=0;
rep(i,1,n){
	// morau dp j->i
	d[i][0]=-1;
	d[i][1]=-1;
	rep[g.edge[i]](j,g.es[i]){
		if(j<i){
			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]);
				}
			}
		}
	}
}
wt(d[n-1][1]);

// jirou kun
d[n-1][0]=0;
d[n-1][1]=0;
rrep(i,n-1){
	// morau dp j->i
	d[i][0]=-1;
	d[i][1]=-1;
	rep[g.edge[i]](j,g.es[i]){
		if(j>i){
			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]);
				}
			}
		}
	}
}
wt(d[0][1]);
0