0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Swift】ワンライナーでACを目指そう|ABC432A - Permute to Maximize【AtCoder】

0
Last updated at Posted at 2025-12-08

コード

  • 1行で簡単にACできます。
import Foundation
print(readLine()!.components(separatedBy: " ").map{ Int($0)! }.sorted(by: {$0 > $1}).map { String($0) }.joined(separator: ""))

実装方針

1. 問題文の読み替え

  • 並び替えられる数字から最大のものを出力してください

    • => 数字を配列にして、配列を大きい順に並び替えたものを文字列として結合して出力してください。

2. 出力処理

2-1. 標準入力を数字にmapする

readLine()!.components(separatedBy: " ").map{ Int($0)! }

2-2. 大きい順に並び替えて文字列に結合しなおす

.sorted(by: {$0 > $1}).map { String($0) }.joined(separator: ""))

謝辞

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?