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;
int MOD = 1e9+7;
int main(){
int n;
cin >> n;
vector<long long int> heights(n);
vector<long long 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 |
---|
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... |