結果

問題 No.2071 Shift and OR
ユーザー 👑 箱星箱星
提出日時 2022-09-16 21:35:26
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,283 bytes
コンパイル時間 15,646 ms
コンパイル使用メモリ 445,132 KB
実行使用メモリ 102,756 KB
最終ジャッジ日時 2024-06-01 12:05:21
合計ジャッジ時間 41,237 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 334 ms
62,204 KB
testcase_01 AC 361 ms
62,556 KB
testcase_02 AC 482 ms
71,476 KB
testcase_03 AC 561 ms
94,444 KB
testcase_04 AC 540 ms
84,824 KB
testcase_05 AC 826 ms
102,004 KB
testcase_06 AC 511 ms
94,332 KB
testcase_07 WA -
testcase_08 AC 525 ms
78,800 KB
testcase_09 AC 557 ms
89,412 KB
testcase_10 AC 590 ms
98,028 KB
testcase_11 AC 886 ms
102,416 KB
testcase_12 AC 966 ms
102,536 KB
testcase_13 AC 757 ms
101,724 KB
testcase_14 AC 327 ms
62,320 KB
testcase_15 AC 677 ms
101,640 KB
testcase_16 AC 699 ms
101,648 KB
testcase_17 AC 805 ms
102,460 KB
testcase_18 AC 360 ms
62,572 KB
testcase_19 AC 941 ms
102,620 KB
testcase_20 AC 970 ms
101,716 KB
testcase_21 AC 1,143 ms
102,756 KB
testcase_22 AC 1,050 ms
102,584 KB
testcase_23 AC 742 ms
92,448 KB
testcase_24 AC 667 ms
86,148 KB
testcase_25 AC 671 ms
92,932 KB
testcase_26 AC 664 ms
86,408 KB
testcase_27 AC 579 ms
92,636 KB
testcase_28 AC 761 ms
92,756 KB
testcase_29 AC 801 ms
93,104 KB
testcase_30 AC 616 ms
95,928 KB
testcase_31 AC 557 ms
83,144 KB
testcase_32 AC 571 ms
85,120 KB
testcase_33 AC 562 ms
96,420 KB
testcase_34 AC 563 ms
95,428 KB
testcase_35 AC 640 ms
95,776 KB
testcase_36 AC 651 ms
96,056 KB
testcase_37 AC 610 ms
96,392 KB
testcase_38 AC 562 ms
96,200 KB
testcase_39 AC 544 ms
89,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val a = Array(n) { nextInt() }
    val m = minOf(n, 16)
    val b = a.take(m)
    val set = mutableSetOf(0)
    fun shift(x: Int) = x / 2 + 32768 * (x % 2)
    for (entry in b) {
        var v = entry
        val setAdd = mutableSetOf<Int>()
        for (i in 0 until 15) {
            v = shift(v)
            for (w in set) {
                setAdd.add(v or w)
            }
        }
        for (add in setAdd) {
            set.add(add)
        }
    }
    println(set.maxOrNull())
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, false)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0