結果
| 問題 | No.365 ジェンガソート | 
| コンテスト | |
| ユーザー |  uafr_cs | 
| 提出日時 | 2016-05-15 20:59:41 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 384 ms / 2,000 ms | 
| コード長 | 2,023 bytes | 
| コンパイル時間 | 3,656 ms | 
| コンパイル使用メモリ | 79,124 KB | 
| 実行使用メモリ | 54,164 KB | 
| 最終ジャッジ日時 | 2024-10-12 02:18:44 | 
| 合計ジャッジ時間 | 10,565 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 41 | 
ソースコード
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();
		}
	}
}
            
            
            
        