#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int r[N][3];
int w[N];
int h[N];
int mod = 1e9 + 7;
int power(int a,int b){
if (b==0)
return 1;
int ans = power(a,b/2);
ans = ans*ans;
ans %= mod;
if (b%2)
ans = ans*a;
return ans%mod;
}
int mod_inv(int k){
return power(k,mod-2);
}
int asd(int a){
int ans = (a*(a+1));
ans = ans%mod;
ans = ans*mod_inv(2);
ans = ans% mod;
return ans;
}
int answer(int W,int H){
int ans = asd(W);
int ans2 = asd(H);
return (ans*ans2)%mod ;
}
signed main(){
int n;
cin>>n;
for (int i=1;i<=n;i++)
cin>>h[i];
int ans = 0;
int W = 0;
for (int i=1;i<=n;i++){
cin>>w[i];
W += w[i];
W %= mod;
}
for (int i=1;i<=n;i++){
ans += answer(W,h[i]);
// cout<<i<<" "<<answer(W,h[i])<<endl;
ans = ans % mod;
ans -= answer(W,h[i-1]);
// cout<<answer(W,h[i-1])<<endl;
if (ans<0)
ans += mod;
W -= w[i];
if (W<0)
W += mod;
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Correct |
17 ms |
2564 KB |
Output is correct |
3 |
Correct |
84 ms |
2652 KB |
Output is correct |
4 |
Correct |
162 ms |
2652 KB |
Output is correct |
5 |
Correct |
177 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2500 KB |
Output is correct |
3 |
Correct |
17 ms |
2652 KB |
Output is correct |
4 |
Correct |
82 ms |
3420 KB |
Output is correct |
5 |
Correct |
176 ms |
4596 KB |
Output is correct |
6 |
Correct |
165 ms |
4692 KB |
Output is correct |
7 |
Correct |
2 ms |
2396 KB |
Output is correct |
8 |
Correct |
17 ms |
2652 KB |
Output is correct |
9 |
Correct |
83 ms |
3672 KB |
Output is correct |
10 |
Correct |
160 ms |
4480 KB |
Output is correct |
11 |
Correct |
165 ms |
4440 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2500 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |