結果
問題 |
No.723 2つの数の和
|
ユーザー |
|
提出日時 | 2018-11-28 00:26:50 |
言語 | Java (openjdk 23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,070 bytes |
コンパイル時間 | 2,376 ms |
コンパイル使用メモリ | 74,392 KB |
実行使用メモリ | 76,756 KB |
最終ジャッジ日時 | 2024-06-24 21:25:14 |
合計ジャッジ時間 | 8,633 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 TLE * 1 -- * 20 |
ソースコード
package net.ipipip0129.yukicoder.No723; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int num_len = scan.nextInt(); int base_num = scan.nextInt(); int[] num_array = new int[num_len]; int ans_cnt = 0; for (int i = 0; i < num_len; i++) { int a = scan.nextInt(); num_array[i] = a; } Arrays.sort(num_array); for (int i = 0; i < num_len; i++) { int sub = base_num - num_array[i]; if (num_array[i] <= base_num) { for (int j = i; j < num_len; j++) { if (sub == num_array[j]) { if (i == j) ans_cnt += 1; else ans_cnt += 2; } else if (sub < num_array[j]) { break; } } } } System.out.println(ans_cnt); } }