結果

問題 No.206 数の積集合を求めるクエリ
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-11 02:11:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5,881 ms / 7,000 ms
コード長 871 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 60,472 KB
実行使用メモリ 4,836 KB
最終ジャッジ日時 2023-10-19 22:44:28
合計ジャッジ時間 26,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,836 KB
testcase_01 AC 2 ms
4,836 KB
testcase_02 AC 2 ms
4,836 KB
testcase_03 AC 2 ms
4,836 KB
testcase_04 AC 2 ms
4,836 KB
testcase_05 AC 3 ms
4,836 KB
testcase_06 AC 4 ms
4,836 KB
testcase_07 AC 3 ms
4,836 KB
testcase_08 AC 4 ms
4,836 KB
testcase_09 AC 3 ms
4,836 KB
testcase_10 AC 3 ms
4,836 KB
testcase_11 AC 3 ms
4,836 KB
testcase_12 AC 13 ms
4,836 KB
testcase_13 AC 11 ms
4,836 KB
testcase_14 AC 9 ms
4,836 KB
testcase_15 AC 7 ms
4,836 KB
testcase_16 AC 7 ms
4,836 KB
testcase_17 AC 73 ms
4,836 KB
testcase_18 AC 38 ms
4,836 KB
testcase_19 AC 67 ms
4,836 KB
testcase_20 AC 38 ms
4,836 KB
testcase_21 AC 46 ms
4,836 KB
testcase_22 AC 46 ms
4,836 KB
testcase_23 AC 68 ms
4,836 KB
testcase_24 AC 5,881 ms
4,836 KB
testcase_25 AC 5,407 ms
4,836 KB
testcase_26 AC 1,589 ms
4,836 KB
testcase_27 AC 1,572 ms
4,836 KB
testcase_28 AC 3,607 ms
4,836 KB
testcase_29 AC 3,318 ms
4,836 KB
testcase_30 AC 2,462 ms
4,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(void)
{
    int a[100000];
    int b[100000];
    int c[100000] = {0};
    int l, m, n, q;
    cin >> l >> m >> n;
    for(int i = 0; i < l; i++)
        cin >> a[i];
    for(int i = 0; i < m; i++)
        cin >> b[i];
    cin >> q;
    sort(a, a + l);
    sort(b, b + m);
    int ii = 0, jj = 0;
    while(ii < l && jj < m) {
        int d = a[ii] - b[jj];
        if(d < 0)
            ii++;
        else if(d <= q) {
            int sj = jj;
            while(true) {
                if(d < 0)
                    break;
                c[d]++;
                if(sj + 1 >= m)
                    break;
                d = a[ii] - b[++sj];
            }
            ii++;
        }
        else
            jj++;
    }
    for(int i = 0; i < q; i++)
        cout << c[i] << endl;
    return 0;
}
0