CF1420E Battle Lemmings
CF1420E Battle Lemmings
大菜鸡参考了两位哥哥的博客才写出来的
zqy1018
夕林山寸
//Proudly using c++11 by gwt
#include
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair pii;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define endl '\n'
#define count2(x) __builtin_popcount(x)
#define countleadingzero(x) __builtin_clz(x)
#define debug(x) cerr << #x << " = " << x << endl;
inline ll read(){//not solve LLONG_MIN LMAX=9,223,372,036,854,775,807
ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0' && ch<='9')s=s*10+ch-'0',ch=getchar();
return s*w;
}
int dp[81][81][81*41];
// i\j\k i in pos j cost k
// show the minnimize numbers of part i "0..0"
int main(){
int n;
cin>>n;
vectornums(n+1);
int tot1=0;
vectorpos1;
for(int i=1;i<=n;++i){
cin>>nums[i];
if(nums[i]==1)pos1.pb(i);
}
int sum=0;
tot1=pos1.size();
sum+=n*(n-1)/2;//every pair of n;
sum-=tot1*(tot1-1)/2;//every pair of 11
sum-=tot1*(n-tot1);//every pair of 10/01
int cost=0;
memset(dp,0x3f,sizeof(dp));
dp[0][0][0]=0;
for(int i=0;i