結果

問題 No.365 ジェンガソート
ユーザー juger_jv
提出日時 2016-04-29 23:50:38
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 74,428 KB
実行使用メモリ 51,820 KB
最終ジャッジ日時 2024-10-04 19:32:19
合計ジャッジ時間 6,867 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 8 TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
class prob365
{
    public static void main(String args[])throws IOException
    {
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	int n=Integer.parseInt(sc.readLine())+1;
	String s[]=sc.readLine().split(" ");
	int a[]=new int[n];
	for(int i=1;i<n;i++)a[i]=Integer.parseInt(s[i-1]);
	int ans=0;
	for(int i=n-1;i>=0;i--)
	    {
		int b[]=new int[n];
		for(int j=1;j<n;j++)b[j]=a[j];
		if(i!=a[i])
		    {
			for(int j=i;b[j]!=i;j--)
			    {
			       
				a[j-1]=b[j];
			    }
			a[i]=i;
			ans++;
		    }
		//for(int j=1;j<n;j++)System.out.print(a[j]+" ");
		//System.out.println();
	    }
	System.out.println(ans);
    }
}
0