結果

問題 No.206 数の積集合を求めるクエリ
ユーザー Kmcode1
提出日時 2015-05-08 23:17:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 5,446 ms / 7,000 ms
コード長 1,034 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 95,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-05 20:30:11
合計ジャッジ時間 39,433 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%d%d%d", &l, &m, &n);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%d", &a[i]);
      |                 ~~~~~^~~~~~~~~~~~~
main.cpp:40:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |                 scanf("%d", &b[j]);
      |                 ~~~~~^~~~~~~~~~~~~
main.cpp:51:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   51 |         scanf("%d", &q);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
using namespace std;
int l, m, n;
#define MAX 100002
vector<int> a;
vector<int> b;
int ans[MAX];
int main(){
	scanf("%d%d%d", &l, &m, &n);
	a.resize(l);
	for (int i = 0; i < l; i++){
		scanf("%d", &a[i]);
	}
	b.resize(m);
	for (int j = 0; j < m; j++){
		scanf("%d", &b[j]);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0; i < b.size(); i++){
		int ind = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
		for (int j = ind; j < a.size(); j++){
			ans[abs(a[j] - b[i])]++;
		}
	}
	int q;
	scanf("%d", &q);
	for (int i = 0; i < q; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}
0