結果

問題 No.723 2つの数の和
ユーザー ohreitetsuohreitetsu
提出日時 2018-08-21 21:52:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 589 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 72,732 KB
実行使用メモリ 12,176 KB
最終ジャッジ日時 2023-08-22 18:08:30
合計ジャッジ時間 5,550 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 46 ms
6,640 KB
testcase_04 AC 65 ms
7,720 KB
testcase_05 AC 57 ms
7,388 KB
testcase_06 AC 61 ms
7,540 KB
testcase_07 AC 24 ms
5,200 KB
testcase_08 AC 28 ms
5,408 KB
testcase_09 AC 64 ms
7,824 KB
testcase_10 AC 24 ms
5,248 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 32 ms
5,752 KB
testcase_13 AC 77 ms
8,076 KB
testcase_14 AC 14 ms
4,508 KB
testcase_15 AC 25 ms
5,340 KB
testcase_16 AC 40 ms
6,320 KB
testcase_17 AC 53 ms
7,176 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,X,A;
	cin>>N>>X;
	int i;
	multimap<int,int> myMap; 
	multimap<int,int>::iterator mit;
	for (i=0;i<N;i++){
		cin>>A;
		myMap.insert(multimap<int,int>::value_type(A,1));
	}
	int num=0;
	while (!myMap.empty()){
		mit=myMap.begin();
		int val=X-(*mit).first;
		if (2*val==X){
			num++;
		}
		myMap.erase(mit);
		mit=myMap.find(val);
		while (mit!=myMap.end()){
			if (val==(*mit).first){
				num+=2;
			}else{
				break;
			}
			mit++;
		}
	}
	cout<<num<<endl;
	return 0;
}
0