結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
tsushima
|
| 提出日時 | 2019-11-22 21:39:47 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 825 bytes |
| 記録 | |
| コンパイル時間 | 997 ms |
| コンパイル使用メモリ | 113,936 KB |
| 実行使用メモリ | 52,960 KB |
| 最終ジャッジ日時 | 2024-10-11 03:03:32 |
| 合計ジャッジ時間 | 21,413 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 10 -- * 5 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}
}
tsushima