算法竞赛2021 ICPC Southeastern Europe Regional Contest_A-series
2022-04-08 15:48 作者:Clayton_Zhou | 我要投稿
//#include "stdafx.h"
#include<cstdio>
#include<cctype>
#include<vector>
#include<algorithm>
#include <queue>
//using namespace std;
int n=3;
int a[1100000]={2021, 11, 21, 10};
int b[1100000]={10, 21, 11, 2021};
int main(){
int x,i,j;
//*
scanf("%d",&n);
for( x=0;x<=n;x++)
scanf("%d",&a[x]);
for( x=0;x<=n;x++)
scanf("%d",&b[x]);
// */
long long cut=0;
int tmp=0;
for(i=n;i>=0;i--)
{
tmp=(b[i]-a[i]+tmp+1)/2;
if(tmp>0)cut+=tmp;
else tmp=0;
//printf("%d\n",tmp);
}
if(tmp)printf("-1\n");
else printf("%lld\n",cut);
return 0;
}