题目描述:
有n堆石头排成一排,标号为0到n-1,第i堆石头有a[i]个石头
每一步你可以从某一堆取一个石头放到相邻的石头堆里
请问需要多少步可以将a数组变成b数组
输入描述:
第一行先输入一个整数n (1 ≤ ≤ 50)
第二行输入n个数ai
第三行输入n个数bi
0 ≤ ai, bi ≤ 106
输出描述:
输出一个整数表示最少的操作步数,如果无法将a数组变成b数组,输出-1
输入:
2
1 2
2 1
2
10 0
0 10
3
0 0 1
1 0 0
9
3 10 0 4 0 0 0 1 0
5 5 0 7 0 0 0 0 1
输出:
1
10
2
9
题意:
题目描述
题解:
直接暴力,从头到尾,比较每一对的差值,一个个比
代码:
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn = 55;
int a