#include <cstring>
#include<iostream>
using namespace std;
#define Size 1000
int main()
{
int box[Size+1];
int pos[Size+1];
memset( pos, 0, sizeof(pos) );
memset( box, 0, sizeof(box) );
int N;
cin>>N;
int sth[Size+1];
int i, j, ans=0;
for( i=0; i<N; i++ )
{
cin>>sth[i];
for( j=1; (100-box[j])<sth[i]; j++ );
if( j>ans )
ans=j;
box[j]+=sth[i];
pos[i]=j;
}
for( int i=0; i<N; i++ )
{
cout<<sth[i]<<" "<<pos[i]<<endl;
}
cout<<ans<<endl;
return 0;
}
2-09. 装箱问题模拟(20)
最新推荐文章于 2023-03-27 20:06:22 发布