結果
| 問題 | No.559 swapAB列 |
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2017-09-08 16:23:11 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
AC
|
| 実行時間 | 203 ms / 2,000 ms |
| コード長 | 567 bytes |
| 記録 | |
| コンパイル時間 | 8,882 ms |
| コンパイル使用メモリ | 456,988 KB |
| 実行使用メモリ | 56,556 KB |
| 最終ジャッジ日時 | 2026-05-14 14:19:44 |
| 合計ジャッジ時間 | 11,440 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
fun main( args : Array<String> ) {
val a = readLine()!!
val ans = a.toList().sortedBy { it }
val bs = a.toMutableList()
//swap scan
when {
bs.size > 1 -> {
var c = 0
scan@ while( true ) {
for( i in (0..bs.size-2)) {
val scope = bs[i]
val next = bs[i+1]
if( scope > next ) {
bs[i] = next
bs[i+1] = scope
c++
}
if( ans == bs )
break@scan
//println(bs)
}
}
println(c)
}
else -> { println(0) }
}
}
💕💖💞