P10995
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair <int, int> a, pair <int, int> b)
{
int ia = a.second, ib = b.second;
return ia < ib;
}
int main()
{
int n, q;
cin >> n >> q;
vector <int> inp(n);
vector <pair <int, int>> tmp;
for (int i = 0; i < n; i++)
{
cin >> inp[i];
tmp.push_back(make_pair(i, inp[i]));
}
sort(tmp.begin(), tmp.end(), cmp);
for (int i = 0; i < q; i++)
{
int t;
cin >> t;
for (int j = 0;; j++)
{
if (t > inp.size() - tmp[j].first)
{
t -= (inp.size() - tmp[j].first);
continue;
}
else
{
cout << tmp[j].first + 1 << ' ' << tmp[j].first + t << endl;
break;
}
}
}
return 0;
}
听取WA声一片