#include<bits/stdc++.h>
using namespace std;
int MOD = 1e9+7;
int main(){
int n;
cin >> n;
vector<int> heights(n);
vector<int> widths(n);
for(int i = 1; i <= n; ++i) cin >> heights[n-i];
for(int i = 1; i <= n; ++i) cin >> widths[n-i];
long long int ans = 0;
long long int W = 0;
long long int H;
for(int i = 0; i < n; ++i){
W += widths[i];
W%=MOD;
long long chooseW = (W*(W+1)/2)%MOD;
if(i == n-1) H = heights[i];
else H = heights[i]- heights[i+1];
long long chooseh = (H*(H+1)/2)%MOD;
ans+= (chooseW*chooseh)%MOD;
if(i != n-1){
ans += (H*chooseW)%MOD;
}
ans%=MOD;
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
308 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
38 ms |
704 KB |
Output is correct |
4 |
Correct |
84 ms |
980 KB |
Output is correct |
5 |
Correct |
90 ms |
1084 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
316 KB |
Output is correct |
3 |
Correct |
8 ms |
468 KB |
Output is correct |
4 |
Correct |
42 ms |
832 KB |
Output is correct |
5 |
Correct |
80 ms |
1328 KB |
Output is correct |
6 |
Correct |
97 ms |
1244 KB |
Output is correct |
7 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |