結果

問題 No.411 昇順昇順ソート
ユーザー hogeki
提出日時 2016-08-13 11:22:54
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 966 bytes
コンパイル時間 1,228 ms
コンパイル使用メモリ 104,832 KB
実行使用メモリ 23,168 KB
最終ジャッジ日時 2024-11-07 16:08:27
合計ジャッジ時間 6,371 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 WA * 2 TLE * 1 -- * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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 = 0;
			foreach(int  j in firstList)
			{
				if(firstMax < j)
					firstMax = j;
			}
			int latterMin = int.MaxValue;
			foreach(int j in latterList)
			{
				if(latterMin > j)
					latterMin = j;
			}
			if(firstMax > latterMin)
				return 1;
			else
				return 0;
		}
		if(i == K)
			return CountOK(i+1);

		if(i > K)
		{
			firstList.Add(i);
			ret+=CountOK(i+1);
			firstList.Remove(firstList.Count-1);
		}
		latterList.Add(i);
		ret+=CountOK(i+1);
		latterList.Remove(latterList.Count-1);

		return ret;
	}
}
0