結果
問題 | No.648 お や す み |
ユーザー | tenten |
提出日時 | 2023-02-15 15:33:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 1,907 bytes |
コンパイル時間 | 2,606 ms |
コンパイル使用メモリ | 90,508 KB |
実行使用メモリ | 37,320 KB |
最終ジャッジ日時 | 2024-07-18 00:44:11 |
合計ジャッジ時間 | 9,446 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 51 ms
37,160 KB |
testcase_01 | AC | 52 ms
37,208 KB |
testcase_02 | AC | 52 ms
36,800 KB |
testcase_03 | AC | 51 ms
37,232 KB |
testcase_04 | AC | 51 ms
36,980 KB |
testcase_05 | AC | 52 ms
36,984 KB |
testcase_06 | AC | 50 ms
36,904 KB |
testcase_07 | AC | 51 ms
37,196 KB |
testcase_08 | AC | 51 ms
36,912 KB |
testcase_09 | AC | 51 ms
37,080 KB |
testcase_10 | AC | 52 ms
37,164 KB |
testcase_11 | AC | 55 ms
37,224 KB |
testcase_12 | AC | 51 ms
36,788 KB |
testcase_13 | AC | 51 ms
36,792 KB |
testcase_14 | AC | 52 ms
37,164 KB |
testcase_15 | AC | 52 ms
36,776 KB |
testcase_16 | AC | 50 ms
36,924 KB |
testcase_17 | AC | 51 ms
36,912 KB |
testcase_18 | AC | 52 ms
36,788 KB |
testcase_19 | AC | 52 ms
37,160 KB |
testcase_20 | AC | 52 ms
37,220 KB |
testcase_21 | AC | 53 ms
36,904 KB |
testcase_22 | AC | 52 ms
36,616 KB |
testcase_23 | AC | 52 ms
37,292 KB |
testcase_24 | AC | 51 ms
36,476 KB |
testcase_25 | AC | 52 ms
36,900 KB |
testcase_26 | AC | 52 ms
37,056 KB |
testcase_27 | AC | 51 ms
37,164 KB |
testcase_28 | AC | 53 ms
36,612 KB |
testcase_29 | AC | 52 ms
36,780 KB |
testcase_30 | AC | 51 ms
36,904 KB |
testcase_31 | AC | 52 ms
36,552 KB |
testcase_32 | AC | 52 ms
37,156 KB |
testcase_33 | AC | 55 ms
37,084 KB |
testcase_34 | AC | 51 ms
37,164 KB |
testcase_35 | AC | 52 ms
36,956 KB |
testcase_36 | AC | 52 ms
36,928 KB |
testcase_37 | AC | 51 ms
36,916 KB |
testcase_38 | AC | 52 ms
37,320 KB |
testcase_39 | AC | 51 ms
37,080 KB |
testcase_40 | AC | 51 ms
37,216 KB |
testcase_41 | AC | 52 ms
36,780 KB |
testcase_42 | AC | 53 ms
36,616 KB |
testcase_43 | AC | 53 ms
36,924 KB |
testcase_44 | AC | 53 ms
36,924 KB |
testcase_45 | AC | 53 ms
36,784 KB |
testcase_46 | AC | 52 ms
36,568 KB |
testcase_47 | AC | 51 ms
36,644 KB |
testcase_48 | AC | 52 ms
37,196 KB |
testcase_49 | AC | 51 ms
36,456 KB |
testcase_50 | AC | 52 ms
37,220 KB |
testcase_51 | AC | 54 ms
37,224 KB |
testcase_52 | AC | 53 ms
36,556 KB |
testcase_53 | AC | 52 ms
37,160 KB |
testcase_54 | AC | 53 ms
37,256 KB |
testcase_55 | AC | 51 ms
36,616 KB |
testcase_56 | AC | 52 ms
36,972 KB |
testcase_57 | AC | 52 ms
36,688 KB |
testcase_58 | AC | 52 ms
36,744 KB |
testcase_59 | AC | 52 ms
36,788 KB |
testcase_60 | AC | 52 ms
36,916 KB |
testcase_61 | AC | 51 ms
36,788 KB |
testcase_62 | AC | 55 ms
37,160 KB |
testcase_63 | AC | 51 ms
36,904 KB |
testcase_64 | AC | 51 ms
36,720 KB |
testcase_65 | AC | 50 ms
37,164 KB |
testcase_66 | AC | 53 ms
37,192 KB |
testcase_67 | AC | 51 ms
36,584 KB |
testcase_68 | AC | 51 ms
37,280 KB |
testcase_69 | AC | 54 ms
36,464 KB |
testcase_70 | AC | 52 ms
36,912 KB |
testcase_71 | AC | 52 ms
36,960 KB |
testcase_72 | AC | 53 ms
37,164 KB |
testcase_73 | AC | 54 ms
37,084 KB |
testcase_74 | AC | 51 ms
37,184 KB |
testcase_75 | AC | 53 ms
37,216 KB |
testcase_76 | AC | 51 ms
37,104 KB |
testcase_77 | AC | 52 ms
36,912 KB |
testcase_78 | AC | 51 ms
36,572 KB |
testcase_79 | AC | 52 ms
37,232 KB |
testcase_80 | AC | 51 ms
36,740 KB |
testcase_81 | AC | 52 ms
36,800 KB |
testcase_82 | AC | 52 ms
37,256 KB |
testcase_83 | AC | 51 ms
37,164 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); long n = sc.nextLong(); long left = 0; long right = Integer.MAX_VALUE; while (right - left > 1) { long m = (left + right) / 2; if (m * (m + 1) / 2 <= n) { left = m; } else { right = m; } } if (left * (left + 1) / 2 == n) { System.out.println("YES"); System.out.println(left); } else { System.out.println("NO"); } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }