結果

問題 No.927 Second Permutation
ユーザー tsushimatsushima
提出日時 2019-11-22 21:39:47
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 825 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 112,312 KB
実行使用メモリ 53,032 KB
最終ジャッジ日時 2024-04-19 10:44:12
合計ジャッジ時間 25,565 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
31,864 KB
testcase_01 AC 24 ms
25,004 KB
testcase_02 AC 23 ms
24,756 KB
testcase_03 AC 24 ms
24,888 KB
testcase_04 AC 24 ms
26,680 KB
testcase_05 AC 25 ms
26,708 KB
testcase_06 AC 24 ms
24,924 KB
testcase_07 AC 24 ms
24,864 KB
testcase_08 AC 288 ms
43,932 KB
testcase_09 AC 26 ms
22,708 KB
testcase_10 AC 628 ms
43,580 KB
testcase_11 AC 1,749 ms
44,620 KB
testcase_12 AC 413 ms
43,268 KB
testcase_13 AC 41 ms
35,636 KB
testcase_14 AC 707 ms
43,924 KB
testcase_15 AC 393 ms
47,732 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 1,955 ms
42,188 KB
testcase_19 TLE -
testcase_20 AC 1,992 ms
46,408 KB
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 1,996 ms
46,168 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);

            for (var i = ans.Length - 2; i >= 0; i--)
            {
                Swap(ref ans[i], ref ans[i + 1]);
                if (ans[0] != '0' && new string(ans) != bef)
                {
                    Console.WriteLine(new string(ans));
                    return;
                }
            }

            Console.WriteLine(-1);
        }

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