結果
| 問題 | No.2071 Shift and OR |
| コンテスト | |
| ユーザー |
urutom
|
| 提出日時 | 2022-10-13 18:12:13 |
| 言語 | Go (1.27.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 533 ms / 2,000 ms |
| + 976µs | |
| コード長 | 621 bytes |
| 記録 | |
| コンパイル時間 | 14,371 ms |
| コンパイル使用メモリ | 270,716 KB |
| 実行使用メモリ | 10,400 KB |
| 最終ジャッジ日時 | 2026-10-10 20:38:34 |
| 合計ジャッジ時間 | 18,728 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
package main
import "fmt"
const maxWord = (1 << 16) - 1
func shift(a int) int {
return (1<<15)*(a%2) + (a / 2)
}
func main() {
var n int
fmt.Scanln(&n)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
if n >= 16 {
fmt.Println(maxWord)
return
}
dp := make([]bool, maxWord+1)
dp[0] = true
for i := 0; i < n; i++ {
x := a[i]
temp := make([]bool, maxWord+1)
for j := 0; j < 16; j++ {
for k := 0; k <= maxWord; k++ {
if dp[k] {
temp[k|x] = true
}
}
x = shift(x)
}
dp = temp
}
for k := maxWord; k > 0; k-- {
if dp[k] {
fmt.Println(k)
return
}
}
}
urutom