結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2018-08-04 12:31:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 589 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 2,262 ms |
コンパイル使用メモリ | 77,620 KB |
実行使用メモリ | 59,548 KB |
最終ジャッジ日時 | 2024-09-19 17:48:24 |
合計ジャッジ時間 | 12,440 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); int X = scan.nextInt(); int l = 100001; long []a = new long[l]; for(int i = 0; i < N; i++) { a[scan.nextInt()] ++; } scan.close(); long ans = 0; for(int i = 0; i < l; i++) { int res = X - i; if(res >= 0 && res <= 100000) { ans += a[i] * a[res]; } } System.out.println(ans); } }