結果

問題 No.1943 消えたAGCT(1)
ユーザー 👑 箱星箱星
提出日時 2022-05-20 21:47:48
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,093 bytes
コンパイル時間 18,435 ms
コンパイル使用メモリ 440,508 KB
実行使用メモリ 61,168 KB
最終ジャッジ日時 2023-10-20 12:17:24
合計ジャッジ時間 28,188 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 310 ms
59,500 KB
testcase_01 AC 318 ms
59,500 KB
testcase_02 AC 317 ms
59,496 KB
testcase_03 AC 315 ms
59,500 KB
testcase_04 AC 315 ms
59,480 KB
testcase_05 AC 313 ms
59,496 KB
testcase_06 AC 318 ms
59,500 KB
testcase_07 AC 318 ms
59,492 KB
testcase_08 AC 315 ms
59,496 KB
testcase_09 AC 401 ms
61,116 KB
testcase_10 AC 416 ms
61,152 KB
testcase_11 AC 409 ms
61,148 KB
testcase_12 AC 411 ms
61,148 KB
testcase_13 AC 407 ms
61,152 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 402 ms
61,116 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 394 ms
61,124 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 427 ms
61,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:6:9: warning: variable 'n' is never used
    val n = nextInt()
        ^

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val s = nextLine()
    val atgc = setOf('A', 'T', 'G', 'C')
    val i = s.indexOfFirst { atgc.contains(it) }
    val j = s.indexOfLast { atgc.contains(it) }
    val c = s.count { atgc.contains(it) }
    if (i == -1) {
        println(0)
    } else {
        println(j - minOf(i, c - 1) + 1)
    }
}

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