結果

問題 No.206 数の積集合を求めるクエリ
ユーザー Tsuneo YoshiokaTsuneo Yoshioka
提出日時 2015-05-08 23:48:36
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,082 bytes
コンパイル時間 519 ms
コンパイル使用メモリ 64,056 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-19 09:00:33
合計ジャッジ時間 4,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 18 ms
4,380 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 12 ms
4,380 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 16 ms
4,376 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int A[10000];
int B[10000];

int L, M;
//int calc(vector<int> &A, vector<int> &B, int v)
int calc(int v)
{
    //int AN = (int)A.size(), BN = (int)B.size();
    int AN = L, BN = M;
    int ap = 0, bp = 0;
    int count = 0;
    while(ap<AN && bp<BN){
        if(A[ap]==B[bp]+v){
        // cout << "ap=" << ap << ",bp=" << bp << endl;
            ap++, bp++;
            count ++;
        }else if(A[ap]>B[bp]+v){
            bp++;
        }else{
            ap++;
        }
    }
    return count;
}
int main(void){
    // Here your code !
    int N;
    cin >> L >> M >> N;
    //vector<int> A, B;
    for(int l=0;l<L;l++){
        int val;
        cin >> val;
        A[l] = val;
        // A.push_back(val);
    }
    for(int m=0;m<M;m++){
        int val;
        cin >> val;
        B[m] = val;
        //B.push_back(val);
    }
    int Q;
    cin >> Q;
    sort(A, A+L);
    sort(B, B+M);
    for(int v=0;v<Q;v++){
        int ret = calc(v);
        cout << ret << endl;
    }
    return 0;
}
0