結果

問題 No.206 数の積集合を求めるクエリ
ユーザー tottoripapertottoripaper
提出日時 2015-05-09 00:23:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,134 ms / 7,000 ms
コード長 850 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 26,696 KB
実行使用メモリ 4,608 KB
最終ジャッジ日時 2023-09-19 09:07:41
合計ジャッジ時間 14,798 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 4 ms
4,384 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 1 ms
4,388 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 AC 23 ms
4,380 KB
testcase_18 AC 3,118 ms
4,608 KB
testcase_19 AC 1,141 ms
4,560 KB
testcase_20 AC 12 ms
4,384 KB
testcase_21 AC 15 ms
4,380 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 617 ms
4,504 KB
testcase_24 AC 31 ms
4,380 KB
testcase_25 AC 784 ms
4,496 KB
testcase_26 AC 3,134 ms
4,504 KB
testcase_27 AC 1,450 ms
4,380 KB
testcase_28 AC 24 ms
4,380 KB
testcase_29 AC 2,341 ms
4,384 KB
testcase_30 AC 20 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Ω\・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]);
    }
}
0