結果
| 問題 | No.927 Second Permutation |
| コンテスト | |
| ユーザー |
tsushima
|
| 提出日時 | 2019-11-22 21:31:07 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 730 bytes |
| 記録 | |
| コンパイル時間 | 3,202 ms |
| コンパイル使用メモリ | 113,688 KB |
| 実行使用メモリ | 28,972 KB |
| 最終ジャッジ日時 | 2024-10-11 02:53:16 |
| 合計ジャッジ時間 | 5,960 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 17 |
コンパイルメッセージ
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);
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;
}
}
}
tsushima