結果

問題 No.871 かえるのうた
ユーザー tentententen
提出日時 2021-03-16 10:32:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,427 bytes
コンパイル時間 1,955 ms
コンパイル使用メモリ 77,904 KB
実行使用メモリ 66,544 KB
最終ジャッジ日時 2024-04-25 10:29:16
合計ジャッジ時間 11,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
37,048 KB
testcase_01 WA -
testcase_02 AC 42 ms
36,980 KB
testcase_03 AC 42 ms
36,884 KB
testcase_04 AC 43 ms
37,220 KB
testcase_05 AC 42 ms
36,772 KB
testcase_06 WA -
testcase_07 AC 45 ms
37,104 KB
testcase_08 AC 78 ms
38,596 KB
testcase_09 AC 83 ms
39,176 KB
testcase_10 AC 47 ms
37,084 KB
testcase_11 AC 62 ms
38,328 KB
testcase_12 AC 146 ms
44,636 KB
testcase_13 AC 90 ms
39,628 KB
testcase_14 AC 338 ms
62,728 KB
testcase_15 AC 347 ms
65,172 KB
testcase_16 AC 402 ms
65,096 KB
testcase_17 AC 340 ms
62,008 KB
testcase_18 AC 151 ms
44,668 KB
testcase_19 WA -
testcase_20 AC 105 ms
41,568 KB
testcase_21 AC 219 ms
51,552 KB
testcase_22 AC 48 ms
36,652 KB
testcase_23 AC 47 ms
36,668 KB
testcase_24 AC 45 ms
36,544 KB
testcase_25 AC 73 ms
38,400 KB
testcase_26 AC 106 ms
40,992 KB
testcase_27 AC 116 ms
42,232 KB
testcase_28 AC 44 ms
36,756 KB
testcase_29 AC 197 ms
51,804 KB
testcase_30 AC 255 ms
55,764 KB
testcase_31 AC 87 ms
39,052 KB
testcase_32 AC 249 ms
54,380 KB
testcase_33 WA -
testcase_34 AC 166 ms
45,012 KB
testcase_35 AC 252 ms
54,156 KB
testcase_36 AC 303 ms
57,828 KB
testcase_37 AC 225 ms
51,340 KB
testcase_38 AC 327 ms
58,276 KB
testcase_39 WA -
testcase_40 AC 214 ms
52,340 KB
testcase_41 AC 46 ms
36,828 KB
testcase_42 AC 214 ms
52,436 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 46 ms
37,080 KB
testcase_47 AC 45 ms
37,028 KB
testcase_48 AC 45 ms
36,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 2);
		int n = Integer.parseInt(first[0]);
		int k = Integer.parseInt(first[1]) - 1;
		String[] second = br.readLine().split(" ", n);
		String[] third = br.readLine().split(" ", n);
		Frog[] frogs = new Frog[n];
		for (int i = 0; i < n; i++) {
		    frogs[i] = new Frog(Long.parseLong(second[i]), Long.parseLong(third[i]));
		}
		int left = k;
		int right = k;
		long min = frogs[k].position - frogs[k].strength;
		long max = frogs[k].position + frogs[k].strength;
		boolean flag = true;
		while (flag) {
		    flag = false;
		    while (left > 0 && frogs[left - 1].position >= min) {
		        min = Math.min(min, frogs[left - 1].position - frogs[left - 1].strength);
		        left--;
		        flag = true;
		    }
		    while (right < n - 1 && frogs[right + 1].position <= max) {
		        max = Math.max(max, frogs[right + 1].position + frogs[right + 1].strength);
		        right++;
		        flag = true;
		    }
		}
		System.out.println(right - left + 1);
   }
   
   static class Frog {
       long position;
       long strength;
       
       public Frog(long position, long strength) {
           this.position = position;
           this.strength = strength;
       }
   }
}
0