結果

問題 No.927 Second Permutation
ユーザー tsushimatsushima
提出日時 2019-11-22 21:31:07
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 730 bytes
コンパイル時間 1,939 ms
コンパイル使用メモリ 114,680 KB
実行使用メモリ 28,972 KB
最終ジャッジ日時 2024-04-19 10:33:39
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
18,560 KB
testcase_01 AC 26 ms
18,816 KB
testcase_02 AC 26 ms
18,944 KB
testcase_03 AC 26 ms
18,944 KB
testcase_04 AC 24 ms
18,944 KB
testcase_05 AC 25 ms
18,944 KB
testcase_06 AC 25 ms
19,072 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 46 ms
20,224 KB
testcase_25 AC 39 ms
19,456 KB
testcase_26 AC 37 ms
19,072 KB
testcase_27 AC 35 ms
18,944 KB
testcase_28 AC 46 ms
20,096 KB
testcase_29 AC 43 ms
19,968 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = Console.ReadLine();
            var ans = X.OrderByDescending(z => z).ToArray();
            var bef = new string(ans);

            Swap(ref ans[ans.Length - 1], ref ans[ans.Length - 2]);

            var last = new string(ans);

            if (last[0] == '0' || bef == last)
                Console.WriteLine(-1);
            else
                Console.WriteLine(last);
        }

        public static void Swap<T>(ref T one, ref T two)
        {
            var temp = one;
            one = two;
            two = temp;
        }
    }
}
0