結果
問題 | No.1211 円環はお断り |
ユーザー | ks2m |
提出日時 | 2020-08-30 14:40:03 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,264 bytes |
コンパイル時間 | 2,788 ms |
コンパイル使用メモリ | 75,476 KB |
実行使用メモリ | 64,228 KB |
最終ジャッジ日時 | 2023-08-09 12:36:03 |
合計ジャッジ時間 | 7,952 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
53,496 KB |
testcase_01 | AC | 41 ms
49,348 KB |
testcase_02 | AC | 43 ms
49,796 KB |
testcase_03 | AC | 43 ms
49,492 KB |
testcase_04 | AC | 43 ms
49,216 KB |
testcase_05 | AC | 46 ms
49,312 KB |
testcase_06 | AC | 43 ms
49,120 KB |
testcase_07 | AC | 47 ms
50,228 KB |
testcase_08 | AC | 42 ms
49,736 KB |
testcase_09 | AC | 59 ms
51,632 KB |
testcase_10 | AC | 48 ms
50,340 KB |
testcase_11 | AC | 54 ms
50,864 KB |
testcase_12 | AC | 45 ms
49,944 KB |
testcase_13 | TLE | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Set; public class Main { static int n, k; static int[] a; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); n = Integer.parseInt(sa[0]); k = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); long sum = 0; a = new int[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); sum += a[i]; } br.close(); long ok = 0; long ng = sum / k + 1; while (Math.abs(ok - ng) > 1) { long mid = (ok + ng) / 2; if (can(mid)) { ok = mid; } else { ng = mid; } } System.out.println(ok); } static boolean can(long mid) { Set<Integer> set = new HashSet<>(); for (int i = 0; i < n; i++) { if (set.contains(i - 1)) { continue; } long sum = 0; int cnt = 0; boolean flg = false; for (int j = i; j < i + n; j++) { int idx = j % n; sum += a[idx]; if (sum >= mid) { cnt++; sum = 0; if (flg) { set.add(idx); } else { flg = true; } } } if (cnt >= k) { return true; } } return false; } }