結果
問題 | No.230 Splarraay スプラレェーイ |
ユーザー | fal_rnd |
提出日時 | 2016-10-30 18:43:01 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,315 bytes |
コンパイル時間 | 2,723 ms |
コンパイル使用メモリ | 80,444 KB |
実行使用メモリ | 80,624 KB |
最終ジャッジ日時 | 2024-05-03 19:55:48 |
合計ジャッジ時間 | 18,726 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 114 ms
46,452 KB |
testcase_01 | AC | 112 ms
40,872 KB |
testcase_02 | AC | 115 ms
41,188 KB |
testcase_03 | AC | 116 ms
41,188 KB |
testcase_04 | AC | 118 ms
40,776 KB |
testcase_05 | AC | 194 ms
42,640 KB |
testcase_06 | AC | 383 ms
47,996 KB |
testcase_07 | AC | 175 ms
42,696 KB |
testcase_08 | AC | 205 ms
45,732 KB |
testcase_09 | AC | 2,198 ms
58,440 KB |
testcase_10 | AC | 732 ms
60,456 KB |
testcase_11 | AC | 1,245 ms
56,312 KB |
testcase_12 | AC | 2,167 ms
58,236 KB |
testcase_13 | AC | 476 ms
48,104 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; class C{ static Scanner s = new Scanner(System.in); static Stage stage; static ArrayList<ArrayList<Event>> events = new ArrayList<ArrayList<Event>>(); static boolean[] updated; static int updatedcount; @SuppressWarnings("unchecked") public static void main(String[] args){ stage = new Stage(Integer.parseInt(s.next())); s.next(); ArrayList<Event> finalevents; ArrayList<Event> list = new ArrayList<Event>(); while(s.hasNext()) { Event e = new Event(Byte.parseByte(s.next()), Integer.parseInt(s.next()), Integer.parseInt(s.next())); list.add(e); if(e.type==State.N) { events.add((ArrayList<Event>) list.clone()); list.clear();; } } finalevents=list; updated = new boolean[stage.stage.length]; for(ArrayList<Event> l:events) { Event bonus_e = l.remove(l.size()-1); paint(l); stage.addBonus(bonus_e.l, bonus_e.r); } if(!finalevents.isEmpty()) paint(finalevents); stage.finish(); System.out.print(stage.scoreA); System.out.print(" "); System.out.println(stage.scoreB); } static void paint(List<Event> l) { updatedcount = stage.stage.length; Arrays.fill(updated, false); for(int i=l.size()-1;i>=0;--i) { Event e = l.get(i); for(int ii=e.l;ii<=e.r;ii++) { if(!updated[ii]) { updated[ii]=true; stage.stage[ii] = e.type; if(--updatedcount==0) break; } } } } } class Stage{ long scoreA=0,scoreB=0; State[] stage; Stage(int size){ stage=new State[size]; Arrays.fill(stage, State.N); } void addBonus(int l,int r) { int a=0,b=0; for(int i=l;i<=r;i++) { State s=stage[i]; if(s!=State.N) { if(s==State.A) { a++; }else { b++; } } } if(a>b) { scoreA += Math.max(a, b); }else if(a<b) { scoreB += Math.max(a, b); } } void finish() { for(State s:stage) { if(s!=State.N) { if(s==State.A) { scoreA++; }else { scoreB++; } } } } } class Event{ State type; int l,r; Event(byte type, int l, int r){ this.type = State.get(type); this.l = l; this.r = r; } } enum State{ N,A,B; static State get(byte v) { if(v==0) { return N; }else if(v==1) { return A; }else { return B; } } }