結果
| 問題 |
No.411 昇順昇順ソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-13 15:33:30 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 41 ms / 2,000 ms |
| コード長 | 1,116 bytes |
| コンパイル時間 | 2,275 ms |
| コンパイル使用メモリ | 105,728 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-11-07 16:18:08 |
| 合計ジャッジ時間 | 3,634 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
class ASCASC2
{
static int N, K;
static List<int> firstList = new List<int>();
static List<int> latterList = new List<int>();
static void Main(String[] args)
{
String[] vals = Console.ReadLine().Split(' ');
N = int.Parse(vals[0]);
K = int.Parse(vals[1]);
firstList.Add(K);
Console.WriteLine(CountOK(1));
}
static int CountOK(int i)
{
int ret = 0;
if(i > N)
{
int firstMax = firstList[firstList.Count-1];
if(latterList.Count == 0)
return 0;
int latterMin = latterList[0];
if(firstMax > latterMin)
{
//DebugWrite();
return 1;
}
else
return 0;
}
if(i == K)
return CountOK(i+1);
if(i > K)
{
firstList.Add(i);
ret+=CountOK(i+1);
firstList.RemoveAt(firstList.Count-1);
}
latterList.Add(i);
ret+=CountOK(i+1);
latterList.RemoveAt(latterList.Count-1);
return ret;
}
static void DebugWrite()
{
foreach(int v in firstList)
{
Console.Write("{0},",v);
}
Console.Write(" ");
foreach(int v in latterList)
{
Console.Write("{0},",v);
}
Console.WriteLine();
}
}