結果

問題 No.723 2つの数の和
ユーザー masamasa
提出日時 2019-01-25 11:09:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 61,124 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2023-10-14 09:48:00
合計ジャッジ時間 2,101 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,248 KB
testcase_01 AC 5 ms
7,288 KB
testcase_02 AC 4 ms
7,108 KB
testcase_03 AC 22 ms
7,492 KB
testcase_04 AC 28 ms
7,616 KB
testcase_05 AC 27 ms
7,664 KB
testcase_06 AC 28 ms
7,676 KB
testcase_07 AC 15 ms
7,560 KB
testcase_08 AC 15 ms
7,276 KB
testcase_09 AC 29 ms
7,500 KB
testcase_10 AC 14 ms
7,276 KB
testcase_11 AC 6 ms
7,304 KB
testcase_12 AC 18 ms
7,288 KB
testcase_13 AC 29 ms
7,604 KB
testcase_14 AC 10 ms
7,424 KB
testcase_15 AC 15 ms
7,440 KB
testcase_16 AC 20 ms
7,352 KB
testcase_17 AC 25 ms
7,404 KB
testcase_18 AC 18 ms
7,664 KB
testcase_19 AC 31 ms
7,696 KB
testcase_20 AC 4 ms
7,276 KB
testcase_21 AC 4 ms
7,088 KB
testcase_22 AC 3 ms
7,328 KB
testcase_23 AC 29 ms
7,716 KB
testcase_24 AC 11 ms
7,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
template<class T> bool maxPointer(T& a, T b) { if (a < b) {a = b;return true;}return false;}
template<class T> int maxReturn(T a, T b) {if (a > b) {return a;} else {return b;}}
template<class T> bool minPointer(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(void){
    int N;
    long X;
    cin >> N >> X;
    int aCount[1000001] = {};
    int a[N];
    long count = 0;
    
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
        aCount[tmp]++;
    }
    
    for (int i = 0; i < N; i++) {
        long target = X - a[i];
        if (target < 0 || target > 1000001) continue;
        count += aCount[X - a[i]];
    }
   
    
    cout << count << endl;
}
0