Type: Default 1000ms 256MiB

放石头

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

有n堆石头排成一排,标号为0到n-1,第i堆石头有a[i]个石头 每一步你可以从某一堆取一个石头放到相邻的石头堆里 请问需要多少步可以将a数组变成b数组

输入描述:

第一行先输入一个整数n (1 ≤n≤ 50) 第二行输入n个数ai 第三行输入n个数bi 0 ≤ ai, bi ≤ 106{10^6}

输出描述:

输出一个整数表示最少的操作步数,如果无法将a数组变成b数组,输出-1

2
1 2
2 1
1
3
0 0 1
1 0 0
2
9
3 10 0 4 0 0 0 1 0
5 5 0 7 0 0 0 0 1
9

SWPU ROUND #3(DIV.3)

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
5
Start at
2021-11-20 9:00
End at
2021-11-20 11:30
Duration
2.5 hour(s)
Host
Partic.
27