#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MODD = 1e9+7;
int mult(int n){
int temp = 1;
if(n%2==0){
temp *= (n/2);
temp %= MODD;
temp *= (n+1);
temp %= MODD;
}
else{
temp *= (n+1/2);
temp %= MODD;
temp *= (n);
temp %= MODD;
}
return temp;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
int h[n];
int w[n];
for(int i=0; i<n; i++){
cin >> h[i];
}
for(int i=0; i<n; i++){
cin >> w[i];
}
int ans = 0;
for(int i=0; i<n; i++){
int temp = mult(w[i]);
temp %= MODD;
temp *= mult(h[i]);
temp %= MODD;
ans += temp;
ans %= MODD;
}
for(int i=0; i<n; i++){
int minn = h[i];
for(int j=i+1; j<n; j++){
minn = min(minn, h[j]);
int temp = w[i]*w[j];
temp %= MODD;
temp *= mult(minn);
temp %= MODD;
ans += temp;
ans %= MODD;
}
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
4 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
5 ms |
348 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 |
Incorrect |
6 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
4 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |