不要让昨天 占据你的今天 夏午晴天

夏午晴天

myschool 1204

http://oj.jxust.edu.cn/problem.php?id=1274

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

int main()
{
    int n, m;
    cin >> n >> m;
    set<int> a;
    set<int> b;
    set<int> ::iterator it = a.begin();
    //set<int> ::iterator ite = b.end();
    for(int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        a.insert(h);
    }
    for(int i = 0; i < m; i++)
    {
        int h;
        cin >> h;
        b.insert(h);
    }
    it = a.begin();
    //ite = b.end();
    int k;
    cin >> k;
    while(k--)
    {
        int x;
        cin >> x;
        int falg = 0;
        for(it = a.begin(); it != a.end(); it++)
        {
            int aim = x - *it;
            if(b.find(aim) != b.end())
            {
                falg = 1;
                cout << "Yes" << endl;
                break;
            }
        }
        /*while(1)
        {
            if((*it + *ite) == x)
            {
                cout << "Yes" << endl;
                break;
            }
            else if(*it + *ite > x)
            {
                ite--;
            }
            else if(*it + *ite < x)
            {
                it++;
            }
            if((it == a.end() && ite == b.end()) || (it == a.begin() && ite == b.end()))
            {
                falg = 1;
                break;
            }
        }*/
        if(!falg)
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

  

posted on 2017-03-11 13:28  夏晴天  阅读(153)  评论(0编辑  收藏  举报

导航

Live2D