結果
問題 |
No.723 2つの数の和
|
ユーザー |
![]() |
提出日時 | 2018-08-24 00:06:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 947 ms |
コンパイル使用メモリ | 69,876 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 18:38:30 |
合計ジャッジ時間 | 2,628 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #include <math.h> #include <string> #include <algorithm> typedef long long ll; #define MIN(x, y) (x < y ? x : y) #define MAX(x, y) (x > y ? x : y) using namespace std; int main(){ int N, X; cin >> N >> X; int a[100001] = {}; int cnt[100001] = {}; for(int i = 0; i < N; ++i){ cin >> a[i]; cnt[a[i]]++; } ll ans = 0; for(int i = 0; i < N; ++i){ int diff = X - a[i]; if(diff >= 0 && diff <= 100000){ ans += cnt[diff]; } } cout << ans << endl; }