結果

問題 No.723 2つの数の和
ユーザー saitam05014081saitam05014081
提出日時 2018-08-18 20:49:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 84,724 KB
実行使用メモリ 12,052 KB
最終ジャッジ日時 2023-08-06 18:19:05
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,128 KB
testcase_01 AC 4 ms
11,204 KB
testcase_02 AC 5 ms
11,176 KB
testcase_03 AC 29 ms
11,824 KB
testcase_04 AC 31 ms
11,860 KB
testcase_05 AC 28 ms
11,792 KB
testcase_06 AC 29 ms
11,832 KB
testcase_07 AC 16 ms
11,448 KB
testcase_08 AC 17 ms
11,584 KB
testcase_09 AC 32 ms
12,052 KB
testcase_10 AC 15 ms
11,476 KB
testcase_11 AC 7 ms
11,200 KB
testcase_12 AC 19 ms
11,532 KB
testcase_13 AC 32 ms
11,968 KB
testcase_14 AC 12 ms
11,308 KB
testcase_15 AC 16 ms
11,528 KB
testcase_16 AC 21 ms
11,620 KB
testcase_17 AC 26 ms
11,816 KB
testcase_18 AC 19 ms
11,920 KB
testcase_19 AC 34 ms
11,916 KB
testcase_20 AC 4 ms
11,140 KB
testcase_21 AC 5 ms
11,200 KB
testcase_22 AC 5 ms
11,200 KB
testcase_23 AC 30 ms
11,892 KB
testcase_24 AC 13 ms
11,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main(){
    long long int n, x;
    cin >> n >> x;
    long long int data[1000010];
    long long int nums[n];
    long long int i;
    long long int ans = 0;
    
    for(i = 0; i < 1000010; i++){
        data[i] = 0;
    }
    
    int a;
    for(i = 0; i < n; i++){
        cin >> a;
        nums[i] = a;
        data[a] += 1;
    }
    
    for(i = 0; i < n; i++){
        if(x-nums[i] >= 0 && x-nums[i]<1000010){
            ans += data[x-nums[i]];
        }
    }
    
    cout << ans << endl;
}
0