#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll mod = 1e9+7;
int main() {
ll N;
cin>>N;
vector<ll> h(N+1), w(N+1),dpf(N+1);
ll res=0;
for(ll i=1;i<=N;i++) {
cin>>h[i];
}
for(ll i=1;i<=N;i++) {
cin>>w[i];
}
for(ll i=1;i<=N;i++) {
ll sum=h[i]*(h[i]+(ll)1)/(ll)2;
ll sumw=w[i]*(w[i]+(ll)1)/(ll)2;
sum%=mod;
sumw%=mod;
dpf[i]=(sum*w[i])%mod+dpf[i-1];
dpf[i]%=mod;
res+=(sum*sumw)%mod;
res+=(dpf[i-1]*w[i])%mod;
res%=mod;
}
cout<<res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
428 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
5 ms |
660 KB |
Output is correct |
3 |
Correct |
23 ms |
1620 KB |
Output is correct |
4 |
Correct |
57 ms |
2780 KB |
Output is correct |
5 |
Correct |
49 ms |
2772 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
604 KB |
Output is correct |
4 |
Correct |
24 ms |
1372 KB |
Output is correct |
5 |
Correct |
48 ms |
2648 KB |
Output is correct |
6 |
Correct |
49 ms |
2904 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
5 ms |
604 KB |
Output is correct |
9 |
Correct |
24 ms |
1372 KB |
Output is correct |
10 |
Correct |
51 ms |
2648 KB |
Output is correct |
11 |
Correct |
40 ms |
2648 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |