http://blog.csdn.net/anniyt/article/details/11722207
/*
车调度问题
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<stack>
#include<map>
using namespace std;
int main()
{
map<int,int> line;
int num,val;
cin>>num;
for(int id=0;id<num;++id)
{
cin>>val;
line.insert(pair<int,int>(id,val));
}
map<int,int>::iterator it=line.begin();
int i=0;
int j=0;
bool flag=true;
while(flag)
{
if(it->second==0)
{
cout<<it->first;
line.erase(it);
it=line.begin();
j++;
}
else
if(j>=4)
{
cout<<it->first;
line.erase(it);
it=line.begin();
j=0;
}
else
{
it++;
if(it==line.end())
{
flag=false;
}
}
}
if(flag==false)
for(it=line.begin();it!=line.end();)
{
cout<<it->first;
line.erase(it);
it=line.begin();
}
system("pause");
return 0;
}