結果

問題 No.365 ジェンガソート
ユーザー uafr_csuafr_cs
提出日時 2016-05-15 20:59:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 2,023 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 79,964 KB
実行使用メモリ 63,996 KB
最終ジャッジ日時 2024-04-20 07:10:24
合計ジャッジ時間 8,677 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
50,544 KB
testcase_01 AC 51 ms
50,372 KB
testcase_02 AC 47 ms
50,180 KB
testcase_03 AC 50 ms
50,324 KB
testcase_04 AC 49 ms
50,352 KB
testcase_05 AC 50 ms
50,224 KB
testcase_06 AC 48 ms
50,236 KB
testcase_07 AC 49 ms
50,496 KB
testcase_08 AC 47 ms
50,260 KB
testcase_09 AC 50 ms
50,260 KB
testcase_10 AC 51 ms
50,136 KB
testcase_11 AC 50 ms
50,296 KB
testcase_12 AC 50 ms
50,452 KB
testcase_13 AC 49 ms
50,448 KB
testcase_14 AC 49 ms
50,220 KB
testcase_15 AC 50 ms
50,580 KB
testcase_16 AC 200 ms
58,408 KB
testcase_17 AC 284 ms
58,680 KB
testcase_18 AC 123 ms
52,956 KB
testcase_19 AC 317 ms
58,936 KB
testcase_20 AC 220 ms
57,332 KB
testcase_21 AC 109 ms
54,516 KB
testcase_22 AC 172 ms
57,784 KB
testcase_23 AC 157 ms
55,592 KB
testcase_24 AC 174 ms
57,784 KB
testcase_25 AC 117 ms
54,560 KB
testcase_26 AC 175 ms
56,220 KB
testcase_27 AC 214 ms
58,292 KB
testcase_28 AC 161 ms
55,432 KB
testcase_29 AC 198 ms
58,296 KB
testcase_30 AC 166 ms
54,792 KB
testcase_31 AC 127 ms
54,724 KB
testcase_32 AC 121 ms
54,500 KB
testcase_33 AC 206 ms
58,340 KB
testcase_34 AC 108 ms
54,208 KB
testcase_35 AC 181 ms
58,436 KB
testcase_36 AC 321 ms
63,996 KB
testcase_37 AC 185 ms
58,180 KB
testcase_38 AC 206 ms
58,404 KB
testcase_39 AC 301 ms
60,920 KB
testcase_40 AC 302 ms
60,744 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Data implements Comparable<Data> {
		int data, index;
		
		public Data(int data, int index){
			this.data  = data;
			this.index = index;
		}
		
		@Override public int compareTo(Data arg0){
			return Integer.compare(arg0.data, this.data);
		}
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();

		PriorityQueue<Data> queue = new PriorityQueue<Data>();
		for(int i = 0; i < N; i++){
			queue.add(new Data(sc.nextInt(), i));
		}
		
		TreeSet<Integer> indexes = new TreeSet<Integer>();
		while(!queue.isEmpty()){
			//System.out.println(queue);
			final Data data = queue.poll();
			
			if(indexes.lower(data.index) != null){
				System.out.println(queue.size() + 1);
				return;
			}else{
				indexes.add(data.index);
			}
		}
		
		System.out.println(0);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}
0