👨🏫 空调
👨🏫 参考题解
import java.util.Scanner;
public class Main
{
static int N = (int) 1e5 + 10;
static int[] a = new int[N];
static int n;
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
for (int i = 1; i <= n; i++)
a[i] = sc.nextInt();
for (int i = 1; i <= n; i++)
{
int t = sc.nextInt();
a[i] -= t;
}
for (int i = n; i > 1; i--)
a[i] -= a[i - 1];
long pos = 0, neg = 0;
for (int i = 1; i <= n; i++)
if (a[i] > 0)
pos += a[i];
else
{
neg -= a[i];
}
System.out.println(Math.max(pos, neg));
}
}