Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define pb push_back
- #define SZ(v) ((int)((v).size()))
- constexpr ll mod = 1e9+7;
- constexpr int N = 1e5+9;
- pair<int, int> a[N];
- void run () {
- int n, q;
- cin >> n >> q;
- for (int i = 0; i < n; ++i) {
- cin >> a[i].first;
- a[i].second = i + 1;
- }
- sort(a, a + n);
- while (q--) {
- ll x;
- cin >> x;
- ll lo = 0, hi = n - 1;
- ll ans = -1;
- while (lo <= hi && ans == -1) {
- ll mid = (lo + hi) / 2;
- if (a[mid].first < x) {
- lo = mid + 1;
- } else if (a[mid].first > x) {
- hi = mid - 1;
- } else {
- ans = a[mid].second;
- }
- }
- if (ans == -1)
- cout << "No\n";
- else
- cout << "Yes " << ans << '\n';
- }
- }
- int main () {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- // freopen("/home/hamoudi/clion/hello.in", "rt", stdin);
- int tt;
- tt = 1;
- // cin >> tt;
- while (tt--)
- run();
- }
- /*
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement