結果
| 問題 |
No.206 数の積集合を求めるクエリ
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-05-09 00:23:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2,854 ms / 7,000 ms |
| コード長 | 850 bytes |
| コンパイル時間 | 107 ms |
| コンパイル使用メモリ | 23,936 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-05 20:52:47 |
| 合計ジャッジ時間 | 12,666 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%d %d %d", &L, &M, &N);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d", &a);
| ~~~~~^~~~~~~~~~
main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | scanf("%d", &b);
| ~~~~~^~~~~~~~~~
main.cpp:48:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
48 | scanf("%d", &Q);
| ~~~~~^~~~~~~~~~
ソースコード
// Ω\・8・)チューン
#include <cstdio>
int L, M, N;
int A[200010], B[200010];
int counter[200010];
int Q;
int main(){
scanf("%d %d %d", &L, &M, &N);
for(int i=0;i<L;i++){
int a;
scanf("%d", &a);
++A[--a];
}
for(int i=0;i<M;i++){
int b;
scanf("%d", &b);
++B[--b];
}
int v, next, t;
for(int i=0,j;i<N;){
while(i < N && B[i] == 0){++i;}
if(i == N){break;}
j = i;
v = 0;
while(j < N && B[j] == 1){
v += A[j++];
}
counter[0] += v;
next = j;
t = 1;
while(j < 2*N){
v += A[j++] - A[i++];
counter[t++] += v;
}
i = next;
}
scanf("%d", &Q);
for(int i=0;i<Q;i++){
printf("%d\n", counter[i]);
}
}
tottoripaper