贪心的题,从左向右推过去即可
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
class MoveStonesEasy {
public:
int get(vector <int>, vector <int>);
};
int MoveStonesEasy::get(vector <int> a, vector <int> b)
{
int sum1 = 0,sum2 = 0;
for(int i = 0; i < a.size() ; i++)
{
sum1 += a[i];
sum2 += b[i];
}
if(sum1!=sum2)
{
return -1;
}
sum1 = 0;
for(int i = 0; i<a.size();i++)
{
if(a[i]<b[i])
{
sum1+=(b[i]-a[i]);
a[i+1] -=(b[i]-a[i]);
}
else if(a[i]>b[i])
{
sum1+=(a[i]-b[i]);
a[i+1]+=(a[i]-b[i]);
}
}
return sum1;
}