#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,m;
int mod=1e9+7;
int clc(int x) { return (((x*(x+1)))/(long long)2)%mod; }
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
vector<int> h(n);
vector<int> w(n);
int totalw=0;
for (int i = 0; i < n; i++) cin>>h[i];
for (int i = 0; i < n; i++) { cin >> w[i]; totalw+=w[i]; }
int outp=0;
for (int i = 0; i < n; i++)
{
int lasth=0;
if(i>0) lasth=h[i-1];
outp+=(clc(totalw%mod)*clc(h[i]%mod))%mod-(clc(totalw%mod)*clc(lasth%mod))%mod;
outp%=mod;
totalw-=w[i];
}
outp%=mod;
cout << outp << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
604 KB |
Output is correct |
3 |
Correct |
11 ms |
1116 KB |
Output is correct |
4 |
Correct |
26 ms |
1884 KB |
Output is correct |
5 |
Correct |
21 ms |
1884 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
3 ms |
604 KB |
Output is correct |
4 |
Correct |
14 ms |
2008 KB |
Output is correct |
5 |
Correct |
22 ms |
3932 KB |
Output is correct |
6 |
Correct |
22 ms |
3932 KB |
Output is correct |
7 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
448 KB |
Output isn't correct |
3 |
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 |
- |