結果
問題 | No.927 Second Permutation |
ユーザー |
![]() |
提出日時 | 2019-11-23 20:40:15 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 46 ms / 2,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 900 ms |
コンパイル使用メモリ | 105,344 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-10-11 07:01:55 |
合計ジャッジ時間 | 2,871 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq;using System;public class Hello{static void Main(){var s = Console.ReadLine().Trim().ToArray();Console.WriteLine(getAns(s));}static string getAns(char[] s){Array.Sort(s);for (int i = 0; i < s.Length - 1; i++){if (s[i] != s[i + 1]){var tmp = s[i];s[i] = s[i + 1];s[i + 1] = tmp;if (s[s.Length - 1] != '0'){Array.Reverse(s);var ans = new string(s);return ans;}else return "-1";}}return "-1";}}