結果
| 問題 |
No.559 swapAB列
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2017-09-08 16:23:11 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 339 ms / 2,000 ms |
| コード長 | 567 bytes |
| コンパイル時間 | 13,316 ms |
| コンパイル使用メモリ | 432,472 KB |
| 実行使用メモリ | 60,392 KB |
| 最終ジャッジ日時 | 2024-11-20 11:45:53 |
| 合計ジャッジ時間 | 15,756 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
コンパイルメッセージ
Main.kt:1:11: warning: parameter 'args' is never used
fun main( args : Array<String> ) {
^
ソースコード
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) }
}
}
💕💖💞