結果
| 問題 | No.365 ジェンガソート |
| コンテスト | |
| ユーザー |
suzu
|
| 提出日時 | 2023-05-17 15:12:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 959 bytes |
| 記録 | |
| コンパイル時間 | 543 ms |
| コンパイル使用メモリ | 115,264 KB |
| 実行使用メモリ | 28,556 KB |
| 最終ジャッジ日時 | 2026-05-25 22:07:34 |
| 合計ジャッジ時間 | 4,802 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 6 TLE * 1 -- * 24 |
コンパイルメッセージ
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 yukicoder
{
class PG
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine());
var blocks = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
var compBlocks = new List<int>(blocks);
compBlocks = compBlocks.OrderBy(c => c).ToList();
int ans = 0;
int i = N - 1;
while(i >= 0)
{
if(compBlocks[i] == blocks[i])
{
i--;
continue;
}
int max = -1;
int maxIndex = -1;
for(int p = i ;p >= 0;p--)//入れ替え元探索
{
if(blocks[p] == compBlocks[i])
{
break;
}else if(max < blocks[p])
{
max = blocks[p];
maxIndex = p;
}
}
for(int q = maxIndex;q > 0;q--)//入れ替え
{
blocks[q] = blocks[q - 1];
}
blocks[0] = max;
ans++;
}
Console.WriteLine(ans);
}
}
}
suzu