結果

問題 No.39 桁の数字を入れ替え
ユーザー MiyamonYMiyamonY
提出日時 2019-09-06 01:49:07
言語 Scheme
(Gauche-0.9.14)
結果
WA  
実行時間 -
コード長 529 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 17,232 KB
最終ジャッジ日時 2023-09-05 06:22:53
合計ジャッジ時間 3,153 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
15,268 KB
testcase_01 AC 49 ms
15,476 KB
testcase_02 AC 48 ms
15,308 KB
testcase_03 AC 49 ms
15,408 KB
testcase_04 AC 50 ms
15,232 KB
testcase_05 AC 50 ms
15,292 KB
testcase_06 AC 49 ms
15,476 KB
testcase_07 AC 49 ms
15,400 KB
testcase_08 WA -
testcase_09 AC 49 ms
15,232 KB
testcase_10 AC 48 ms
15,424 KB
testcase_11 AC 48 ms
15,240 KB
testcase_12 AC 48 ms
15,428 KB
testcase_13 AC 52 ms
15,216 KB
testcase_14 AC 49 ms
15,272 KB
testcase_15 AC 49 ms
15,212 KB
testcase_16 AC 51 ms
17,232 KB
testcase_17 AC 50 ms
15,444 KB
testcase_18 AC 47 ms
15,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(use scheme.vector)
(use gauche.collection)
(use util.combinations)

(let* ((n (read)))
  (define vec (vector-map char->integer (string->vector (number->string n))))
  (print (apply max
		#?=(let loop ((is (combinations (iota (vector-length vec)) 2)))
		     (cond ((null? is) '())
			   (else
			    (let ((vec-copied (vector-copy vec))
				  (pair (car is)))
			      (vector-swap! vec-copied (car pair) (cadr pair))
			      (cons (string->number (list->string (map integer->char vec-copied)))
				    (loop (cdr is))))))))))
0