結果
問題 | No.2218 Multiple LIS |
ユーザー | Hima |
提出日時 | 2023-03-02 21:45:16 |
言語 | Go (1.22.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,467 bytes |
コンパイル時間 | 12,069 ms |
コンパイル使用メモリ | 222,920 KB |
実行使用メモリ | 20,456 KB |
最終ジャッジ日時 | 2023-10-17 17:38:59 |
合計ジャッジ時間 | 18,541 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
11,984 KB |
testcase_01 | AC | 3 ms
7,820 KB |
testcase_02 | AC | 5 ms
14,084 KB |
testcase_03 | AC | 4 ms
9,896 KB |
testcase_04 | AC | 3 ms
9,896 KB |
testcase_05 | AC | 3 ms
9,896 KB |
testcase_06 | AC | 3 ms
9,896 KB |
testcase_07 | AC | 3 ms
9,896 KB |
testcase_08 | AC | 3 ms
9,896 KB |
testcase_09 | AC | 3 ms
9,896 KB |
testcase_10 | AC | 3 ms
9,896 KB |
testcase_11 | AC | 9 ms
16,356 KB |
testcase_12 | AC | 46 ms
18,548 KB |
testcase_13 | AC | 122 ms
18,556 KB |
testcase_14 | AC | 92 ms
18,560 KB |
testcase_15 | AC | 93 ms
18,556 KB |
testcase_16 | AC | 32 ms
16,484 KB |
testcase_17 | AC | 129 ms
18,548 KB |
testcase_18 | AC | 16 ms
18,544 KB |
testcase_19 | AC | 35 ms
16,492 KB |
testcase_20 | AC | 95 ms
18,564 KB |
testcase_21 | AC | 753 ms
20,456 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
ソースコード
package main import ( "bufio" "fmt" "os" "sort" "strconv" ) var sc = bufio.NewScanner(os.Stdin) var out = bufio.NewWriter(os.Stdout) func main() { //bufサイズ以上の文字列入力が必要な場合は拡張すること buf := make([]byte, 9*1024*1024) sc.Buffer(buf, bufio.MaxScanTokenSize) sc.Split(bufio.ScanWords) n := nextInt() a := nextIntSlice(n) ans := solve(n, a) PrintInt(ans) } func divide(x int) []int { m := make(map[int]struct{}) for i := 1; i*i <= x; i++ { if x%i == 0 { m[i] = struct{}{} m[x/i] = struct{}{} } } var res []int for k := range m { res = append(res, k) } sort.Ints(res) return res } func solve(n int, a []int) int { dp := make([]int, int(1e5)+1) //make(map[int]int) dp[0] = 0 for i := 1; i <= n; i++ { next := make([]int, int(1e5)+1) //make(map[int]int) for k := range dp { next[k] = dp[k] } d := divide(a[i-1]) next[a[i-1]] = 1 for _, v := range d { next[a[i-1]] = Max(next[a[i-1]], dp[v]+1) } dp = next } var ans int for _, v := range dp { ans = Max(ans, v) } return ans } func nextInt() int { sc.Scan() i, _ := strconv.Atoi(sc.Text()) return int(i) } func nextIntSlice(n int) []int { s := make([]int, n) for i := range s { s[i] = nextInt() } return s } func PrintInt(x int) { defer out.Flush() fmt.Fprintln(out, x) } func Min(x, y int) int { if x < y { return x } return y } func Max(x, y int) int { if x < y { return y } return x }