結果
問題 | No.2095 High Rise |
ユーザー |
![]() |
提出日時 | 2022-10-16 08:46:55 |
言語 | Go (1.23.4) |
結果 |
TLE
|
実行時間 | - |
コード長 | 797 bytes |
コンパイル時間 | 10,744 ms |
コンパイル使用メモリ | 225,384 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-06-27 06:07:33 |
合計ジャッジ時間 | 22,135 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 TLE * 2 -- * 4 |
ソースコード
package main import "fmt" func min(a, b int) int { if a < b { return a } return b } func main() { var n, m int fmt.Scanln(&n, &m) a := make([]int, m) dp := make([]int, m) for j := 0; j < m; j++ { fmt.Scan(&a[j]) } if n == 1 { fmt.Println(0) return } b := make([]int, m) for j := 0; j < m; j++ { fmt.Scan(&b[j]) dp[j] = a[j] + b[j] } a = b for i := 2; i < n; i++ { k := 0 minVal := dp[0] for j := 1; j < m; j++ { if dp[j] < minVal { k = j minVal = dp[j] } } nextA := make([]int, m) nextDP := make([]int, m) for j := 0; j < m; j++ { fmt.Scan(&nextA[j]) nextDP[j] = nextA[j] + min(dp[j], dp[k]+a[j]) } a = nextA dp = nextDP } ans := dp[0] for j := 1; j < m; j++ { if dp[j] < ans { ans = dp[j] } } fmt.Println(ans) }