結果
| 問題 | No.2071 Shift and OR | 
| コンテスト | |
| ユーザー |  urutom | 
| 提出日時 | 2022-10-13 18:12:13 | 
| 言語 | Go (1.23.4) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,284 ms / 2,000 ms | 
| コード長 | 621 bytes | 
| コンパイル時間 | 13,593 ms | 
| コンパイル使用メモリ | 228,836 KB | 
| 実行使用メモリ | 6,528 KB | 
| 最終ジャッジ日時 | 2024-06-26 12:06:07 | 
| 合計ジャッジ時間 | 18,747 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
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
		}
	}
}
            
            
            
        