# [笔试]地域划分

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int>iVec;
int Num;
cin>>Num;
for(int i = 0; i < Num;i++)
{
int iEveryNum;
cin>>iEveryNum;
iVec.push_back(iEveryNum);
}
vector<int>iVec1;
for(int i = 0; i <= iVec.size();i++)
{
int icount0 = 0;
int icount1 = 0;
if(i == 0)
{
icount1 = count(iVec.begin(),iVec.end(),1);
icount0 = count(iVec.begin(),iVec.end(),0);
iVec1.push_back((icount1<icount0)?icount1:icount0);
}
else if(i == iVec.size())
{
icount1 = count(iVec.begin(),iVec.end(),1);
icount0 = count(iVec.begin(),iVec.end(),0);
iVec1.push_back((icount1<icount0)?icount1:icount0);
}
else
{
int totalNum1,totalNum2;
icount1 = count(iVec.begin(),iVec.begin()+i,1);
icount0 = count(iVec.begin()+i,iVec.end(),0);
totalNum1 = icount1+icount0;
icount0 = count(iVec.begin(),iVec.begin()+i,0);
icount1 = count(iVec.begin()+i,iVec.end(),1);
totalNum2 = icount1+icount0;
iVec1.push_back((totalNum1 < totalNum2)?totalNum1:totalNum2);
}
}
vector<int>iVec3;
iVec3 = iVec1;
sort(iVec3.begin(),iVec3.end());
vector<int>::iterator it = iVec1.begin();
it = find(iVec1.begin(),iVec1.end(),iVec3[0]);
cout<<it-iVec1.begin()<<" "<<it-iVec1.begin()+1<<endl;
system("pause");
return 0;
}



#### 地域划分-Java

2016-04-20 16:55:26

#### 网络区域划分

2008-04-01 08:30:00

#### 地域划分

2016-04-21 13:28:06

#### Java根据IP地址获取详细地域信息

2016-09-28 09:55:32

2006-04-28 19:43:00

#### [编程题]地域划分

2016-04-25 20:26:56

#### 中国互联网的地理分布：网民的整体分布和人口分布

2012-11-28 10:10:14

#### 网络实验（四跨交换机的VLAN的划分）

2013-05-30 20:32:38

#### 阿里云服务器哪个地域好？从用户体验的角度浅谈如何对其进行选择

2017-12-13 19:20:59

#### 牛客网答题笔记---地域划分

2016-09-04 12:25:45