#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int MAX_N = 1e5+1;
const int mod =1e9+7;
int h[MAX_N];
int w[MAX_N];
int nbp(int u){
return (u*(u+1LL)/2LL)%mod;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
int sw = 0;
vector<pair<int, int>> ev;
for(int i = 0; i<n; i++){
cin>>h[i];
}
for(int i = 0; i<n; i++){
cin>>w[i];
sw = (sw+w[i])%mod;
}
int res= 0;
for(int i = 0; i<n; i++){
sw =(sw -w[i] +mod)%mod;
res= (res + (nbp(h[i])* ((w[i]* sw)%mod + nbp(w[i]))%mod)%mod)%mod;
}
cout<<res<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
480 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
604 KB |
Output is correct |
3 |
Correct |
9 ms |
1116 KB |
Output is correct |
4 |
Correct |
17 ms |
1884 KB |
Output is correct |
5 |
Correct |
17 ms |
1792 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
604 KB |
Output is correct |
4 |
Correct |
8 ms |
1056 KB |
Output is correct |
5 |
Correct |
18 ms |
3816 KB |
Output is correct |
6 |
Correct |
18 ms |
3812 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
9 ms |
2140 KB |
Output is correct |
10 |
Correct |
16 ms |
3676 KB |
Output is correct |
11 |
Correct |
18 ms |
3756 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |