输入样例:
8
60 70 80 90 30 40 10 20
输出样例:
60 1
70 2
80 3
90 4
30 1
40 5
10 1
20 2
5
#include <iostream>
using namespace std;
int main()
{
int i, n, a, count = 0;
int box[1000];
for (i = 0; i < 1000; i++)
box[i] = 100;
cin >> n;
a = n;
while (a--)
{
int temp;
cin >> temp;
for (i = 0; i < n; i++)
{
if (box[i] >= temp)
{
count = (i > count) ? i : count;
cout << temp << " " << i + 1 << endl;
box[i] -= temp;
break;
}
}
}
cout << count + 1 << endl;
return 0;
}