結果
問題 |
No.618 labo-index
|
ユーザー |
![]() |
提出日時 | 2020-02-13 11:47:23 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,932 ms / 6,000 ms |
コード長 | 1,601 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 79,112 KB |
実行使用メモリ | 65,844 KB |
最終ジャッジ日時 | 2024-10-05 11:26:02 |
合計ジャッジ時間 | 24,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); ArrayList<Long> order = new ArrayList<>(); ArrayList<Long> current = new ArrayList<>(); current.add(Long.MIN_VALUE); current.add(Long.MAX_VALUE); long added = 0; StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int t = sc.nextInt(); int x = sc.nextInt(); if (t == 1) { int left = 0; int right = current.size() - 1; long y = x - added; while (right - left > 1) { int m = (left + right) / 2; if (current.get(m) <= y) { left = m; } else { right = m; } } current.add(right, y); order.add(y); } else if (t == 2) { current.remove(order.get(x - 1)); } else { added += x; } int left = 0; int right = current.size() - 1; while(right - left > 1) { int m = (left + right) / 2; if (current.get(m) + added >= current.size() - m - 1) { right = m; } else { left = m; } } sb.append(current.size() - right - 1).append("\n"); } System.out.print(sb); } }