This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MODD = 1e9+7;
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++){
ans += (w[i]+1)*(w[i])*(h[i]+1)*(h[i])/4;
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]);
ans += w[i]*w[j]*(minn*(minn+1)/2);
ans %= MODD;
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |