結果

問題 No.2071 Shift and OR
ユーザー 👑 箱星箱星
提出日時 2022-09-16 21:35:26
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,283 bytes
コンパイル時間 14,393 ms
コンパイル使用メモリ 429,516 KB
実行使用メモリ 81,636 KB
最終ジャッジ日時 2023-08-23 14:33:41
合計ジャッジ時間 43,887 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 316 ms
56,760 KB
testcase_01 AC 346 ms
57,284 KB
testcase_02 AC 476 ms
62,332 KB
testcase_03 AC 617 ms
74,220 KB
testcase_04 AC 561 ms
63,852 KB
testcase_05 AC 941 ms
81,636 KB
testcase_06 AC 501 ms
67,680 KB
testcase_07 WA -
testcase_08 AC 551 ms
61,552 KB
testcase_09 AC 580 ms
65,680 KB
testcase_10 AC 631 ms
69,904 KB
testcase_11 AC 960 ms
80,248 KB
testcase_12 AC 1,071 ms
80,332 KB
testcase_13 AC 842 ms
80,944 KB
testcase_14 AC 311 ms
56,916 KB
testcase_15 AC 716 ms
77,528 KB
testcase_16 AC 756 ms
75,456 KB
testcase_17 AC 1,045 ms
78,092 KB
testcase_18 AC 342 ms
57,528 KB
testcase_19 AC 1,040 ms
79,704 KB
testcase_20 AC 1,133 ms
80,096 KB
testcase_21 AC 1,242 ms
79,404 KB
testcase_22 AC 1,164 ms
78,340 KB
testcase_23 AC 722 ms
64,496 KB
testcase_24 AC 621 ms
59,996 KB
testcase_25 AC 647 ms
59,560 KB
testcase_26 AC 632 ms
62,500 KB
testcase_27 AC 559 ms
59,344 KB
testcase_28 AC 737 ms
67,284 KB
testcase_29 AC 720 ms
65,452 KB
testcase_30 AC 657 ms
76,204 KB
testcase_31 AC 510 ms
63,968 KB
testcase_32 AC 567 ms
63,824 KB
testcase_33 AC 569 ms
66,500 KB
testcase_34 AC 567 ms
65,148 KB
testcase_35 AC 647 ms
69,812 KB
testcase_36 AC 704 ms
75,964 KB
testcase_37 AC 670 ms
66,492 KB
testcase_38 AC 584 ms
66,436 KB
testcase_39 AC 567 ms
69,436 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