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)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
18220 KB |
Output is correct |
2 |
Incorrect |
47 ms |
19128 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
18208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
44 ms |
18172 KB |
Output is correct |
2 |
Incorrect |
46 ms |
18984 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
18988 KB |
Output is correct |
2 |
Correct |
56 ms |
21612 KB |
Output is correct |
3 |
Correct |
81 ms |
28120 KB |
Output is correct |
4 |
Correct |
128 ms |
35852 KB |
Output is correct |
5 |
Correct |
126 ms |
36796 KB |
Output is correct |
6 |
Correct |
41 ms |
18208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18156 KB |
Output is correct |
2 |
Correct |
42 ms |
18920 KB |
Output is correct |
3 |
Correct |
55 ms |
21536 KB |
Output is correct |
4 |
Correct |
91 ms |
28152 KB |
Output is correct |
5 |
Correct |
125 ms |
35896 KB |
Output is correct |
6 |
Correct |
129 ms |
36792 KB |
Output is correct |
7 |
Correct |
43 ms |
18984 KB |
Output is correct |
8 |
Correct |
58 ms |
21440 KB |
Output is correct |
9 |
Correct |
96 ms |
30368 KB |
Output is correct |
10 |
Correct |
129 ms |
37084 KB |
Output is correct |
11 |
Correct |
132 ms |
36164 KB |
Output is correct |
12 |
Correct |
37 ms |
18288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
18120 KB |
Output is correct |
2 |
Incorrect |
44 ms |
18904 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
34 ms |
18220 KB |
Output is correct |
2 |
Incorrect |
47 ms |
19128 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |