結果

問題 No.365 ジェンガソート
ユーザー hhgfhn1
提出日時 2018-10-19 15:17:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 679 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 2,444 ms
コンパイル使用メモリ 75,280 KB
実行使用メモリ 59,772 KB
最終ジャッジ日時 2024-11-17 14:09:21
合計ジャッジ時間 20,805 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n=scanner.nextInt();
		int a[]=new int[n];
		int max=0;
		int ind=0;
		for(int i=0;i<n;i++){
			a[i]=scanner.nextInt();
			if(a[i]>max){
				max=a[i];
				ind=i;
			}
		}
		int ax[]=deepCopy(a);
		Arrays.sort(ax);
		int oks=0;
		int j=ax.length-1;
		for(int i=ind;i>=0;i--){
			if(a[i]==ax[j]){
				oks++;
				j--;
			}
		}
		System.out.println(a.length-oks);
		
	}
	
	private static int[] deepCopy(int[] array) {
		int[] newArray = new int[array.length];
		System.arraycopy(array, 0, newArray, 0, array.length);
		return newArray;
	}
}
0