Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* [A][M][C][B][N] / [K][R][I][P][6][8] */
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const char sp = ' ', nl = '\n';
- const int MOD = 1999999973;
- ifstream fin("colina.in");
- ofstream fout("colina.out");
- int bs(vector<pair<int, int>>& v, int x) {
- int st = -1, dr = v.size();
- while (dr - st > 1) {
- int mij = (st + dr) / 2;
- if (v[mij].first < x)
- st = mij;
- else
- dr = mij;
- }
- if (dr == v.size() + 1 || v[dr].first != x)
- return -1;
- else
- return dr;
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0), cout.tie(0);
- int n, q, poz(1);
- fin >> n >> q;
- vector<pair<int, int>> v(n);
- for (pair<int, int>& p : v) {
- fin >> p.first;
- p.second = poz++;
- }
- sort(v.begin(), v.end());
- while (q--) {
- int val, idx;
- fin >> val;
- idx = bs(v, val);
- if (idx != -1) {
- fout << "DA" << sp << v[idx].second;
- if (idx + 1 < n)
- if (v[idx + 1].first == val)
- fout << sp << v[idx + 1].second;
- fout << nl;
- }
- else
- fout << "NU" << nl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment