結果

問題 No.723 2つの数の和
ユーザー vividrabbit
提出日時 2018-11-17 15:45:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 837 ms
コンパイル使用メモリ 71,252 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2024-12-24 14:34:09
合計ジャッジ時間 2,573 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<unordered_map>

using namespace std;

int main(){
    int input_num;
    cin >> input_num;
    int sum;
    cin >> sum;
    int array[input_num];
    for(int i=0;i<input_num;i++){
        cin >> array[i];
    }
    long output = 0;
    
    unordered_map<int,int> map;
    for(int i=0;i<input_num;i++){
        if(map[array[i]] >= 1) map[array[i]] += 1;
        else map[array[i]] = 1;
    }
    
    for(int i=0;i<input_num;i++){
        output += map[sum-array[i]];
    }

    cout << output << endl;
    return 0;
}
0