結果
問題 | No.871 かえるのうた |
ユーザー | k_6101 |
提出日時 | 2019-12-07 17:29:04 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,633 bytes |
コンパイル時間 | 2,543 ms |
コンパイル使用メモリ | 82,820 KB |
実行使用メモリ | 64,588 KB |
最終ジャッジ日時 | 2024-06-07 17:25:12 |
合計ジャッジ時間 | 23,574 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 114 ms
41,644 KB |
testcase_01 | WA | - |
testcase_02 | AC | 120 ms
41,576 KB |
testcase_03 | AC | 124 ms
41,464 KB |
testcase_04 | WA | - |
testcase_05 | AC | 126 ms
41,408 KB |
testcase_06 | WA | - |
testcase_07 | AC | 125 ms
41,268 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 172 ms
43,204 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 1,050 ms
64,588 KB |
testcase_15 | WA | - |
testcase_16 | AC | 1,081 ms
62,956 KB |
testcase_17 | AC | 1,018 ms
62,116 KB |
testcase_18 | AC | 404 ms
48,764 KB |
testcase_19 | WA | - |
testcase_20 | AC | 268 ms
49,236 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 121 ms
41,260 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 120 ms
41,284 KB |
testcase_29 | AC | 641 ms
51,096 KB |
testcase_30 | WA | - |
testcase_31 | AC | 197 ms
45,448 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 438 ms
50,848 KB |
testcase_35 | WA | - |
testcase_36 | AC | 773 ms
53,976 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 589 ms
54,596 KB |
testcase_41 | AC | 115 ms
41,152 KB |
testcase_42 | AC | 556 ms
52,844 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | AC | 113 ms
41,440 KB |
testcase_47 | AC | 112 ms
41,348 KB |
testcase_48 | AC | 115 ms
41,256 KB |
ソースコード
import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== TreeMap<Long, Long> map = new TreeMap<>(); public void solve() { int N = Integer.parseInt(sc.next()); int K = Integer.parseInt(sc.next()); long[] X = new long[N]; long[] A = new long[N]; for (int i = 0; i < N; i++) { X[i] = Long.parseLong(sc.next()); } for (int i = 0; i < N; i++) { A[i] = Long.parseLong(sc.next()); } for (int i = 0; i < N; i++) { map.put(X[i], A[i]); } long min = X[K-1]; long lkey = X[K-1] - A[K-1] - 1; Entry<Long, Long> low; while(true) { low = map.higherEntry(lkey); if(low == null || low.getKey() == min) break; // out.println(" low : min = " + min + " lkey = " + lkey // + " X = " + low.getKey() + " A = " + low.getValue()); min = low.getKey(); lkey = low.getKey() - low.getValue() - 1; } long max = X[K-1]; long rkey = X[K-1] + A[K-1] + 1; Entry<Long, Long> high; while(true) { high = map.lowerEntry(rkey); if(high == null || high.getKey() == max) break; // out.println(" high : max = " + max + " rkey = " + rkey // + " X = " + low.getKey() + " A = " + low.getValue()); max = high.getKey(); rkey = high.getKey() + high.getValue() + 1; } int ans = 0; for (int i = 0; i < N; i++) { if(X[i] >= min && X[i] <= max) ans++; } out.println(ans); } class PP{ public int key, val; public PP(int key, int val) { this.key = key; this.val = val; } public int getKey() { return key; } public void setKey(int key) { this.key = key; } public int getVal() { return val; } public void setVal(int val) { this.val = val; } } }