結果

問題 No.723 2つの数の和
ユーザー masamasa
提出日時 2019-01-25 10:41:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 62,640 KB
実行使用メモリ 7,916 KB
最終ジャッジ日時 2023-10-14 09:47:37
合計ジャッジ時間 1,957 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,316 KB
testcase_01 AC 3 ms
7,240 KB
testcase_02 AC 4 ms
7,248 KB
testcase_03 AC 23 ms
7,572 KB
testcase_04 AC 28 ms
7,620 KB
testcase_05 AC 26 ms
7,648 KB
testcase_06 AC 31 ms
7,680 KB
testcase_07 AC 14 ms
7,516 KB
testcase_08 AC 15 ms
7,436 KB
testcase_09 AC 28 ms
7,816 KB
testcase_10 AC 14 ms
7,548 KB
testcase_11 AC 6 ms
7,336 KB
testcase_12 AC 18 ms
7,452 KB
testcase_13 AC 29 ms
7,764 KB
testcase_14 AC 10 ms
7,364 KB
testcase_15 AC 15 ms
7,408 KB
testcase_16 AC 20 ms
7,484 KB
testcase_17 AC 24 ms
7,564 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 4 ms
7,296 KB
testcase_21 AC 3 ms
7,236 KB
testcase_22 AC 3 ms
7,316 KB
testcase_23 AC 29 ms
7,664 KB
testcase_24 AC 11 ms
7,384 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];
    int count = 0;
    
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        a[i] = tmp;
        aCount[tmp]++;
    }
    
    for (int i = 1; i <= N; i++) {
        long target = X - a[i-1];
        if (target < 0 || target > 1000001) continue;
        count += aCount[X - a[i-1]];
    }
   
    
    cout << count << endl;
}
0