This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
MOD = 1000000007
inv2 = pow(2, MOD-2, MOD)
def calc_num(w, h):
return w*(w+1)*h*(h+1)*inv2*inv2 % MOD
N = int(input())
h, w = [0], [0]
h += list(map(int, input().split()))
w += list(map(int, input().split()))
rsm = 0
scr = 0
for i in range(N, 0, -1):
rsm += w[i]
scr += calc_num(rsm, h[i]) - calc_num(rsm, h[i-1])
scr %= MOD
print(scr)
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |