#include <iostream>
#include <queue>
using namespace std;
struct pearl
{
int h, x;
bool operator < (const pearl& a) const
{
return x < a.x;
}
};
priority_queue <pearl> q;
int n,m;
int main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
pearl a;
cin >> a.x;
a.h = i;
q.push(a);
}
while (!q.empty())
{
pearl t = q.top();
q.pop();
pearl u = q.top();
q.pop();
for (int i = 1; i <= u.x; i++)
cout << t.h << " " << u.h << endl;
t.x -= u.x;
if(t.x!=0)
q.push(t);
}
return 0;
}
题解里用优先队列的每次输出一对珠子AC,为何我每次输出多对珠子TLE?