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>
#define ll long long int
using namespace std;
ll mod = 1e9+7;
int main() {
ll N;
cin>>N;
vector<ll> h(N+1), w(N+1),dpf(N+1);
ll res=0;
for(ll i=1;i<=N;i++) {
cin>>h[i];
}
for(ll i=1;i<=N;i++) {
cin>>w[i];
}
for(ll i=1;i<=N;i++) {
ll sum=h[i]*(h[i]+(ll)1)/(ll)2;
ll sumw=w[i]*(w[i]+(ll)1)/(ll)2;
sum%=mod;
sumw%=mod;
dpf[i]=(sum*w[i])%mod+dpf[i-1];
dpf[i]%=mod;
res+=(sum*sumw)%mod;
res+=(dpf[i-1]*w[i])%mod;
res%=mod;
}
cout<<res;
}
# | 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... |