結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2015-09-01 01:06:51 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 142 ms / 5,000 ms |
| コード長 | 1,532 bytes |
| コンパイル時間 | 2,388 ms |
| コンパイル使用メモリ | 86,056 KB |
| 実行使用メモリ | 54,432 KB |
| 最終ジャッジ日時 | 2024-12-31 11:13:11 |
| 合計ジャッジ時間 | 7,451 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static class Block implements Comparable<Block> {
boolean is_white;
int size;
public Block(boolean is_white, int size) {
super();
this.is_white = is_white;
this.size = size;
}
@Override
public int compareTo(Block o) {
return o.size - this.size;
}
}
public static int playout(PriorityQueue<Block> queue, boolean first_blk){
boolean first = true;
boolean prev_color = true;
int prev_size = Integer.MAX_VALUE;
int count = 0;
while(!queue.isEmpty()){
Block blk = queue.poll();
if(first){
if(blk.is_white == first_blk){ continue; }
else{
first = false;
}
}else if(prev_color == blk.is_white){
continue;
}else if(prev_size <= blk.size){
continue;
}
prev_color = blk.is_white;
prev_size = blk.size;
count++;
}
return count;
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
PriorityQueue<Block> queue = new PriorityQueue<Block>();
final int Nw = sc.nextInt();
for(int i = 0; i < Nw; i++){
queue.add(new Block(true, sc.nextInt()));
}
final int Nb = sc.nextInt();
for(int i = 0; i < Nb; i++){
queue.add(new Block(false, sc.nextInt()));
}
System.out.println(Math.max(playout(new PriorityQueue<Block>(queue), true), playout(new PriorityQueue<Block>(queue), false)));
}
}
uafr_cs