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
int n,m;
int mod=1e9+7;
int clc(int x) { return (((x*(x+1)))/(long long)2)%mod; }
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
vector<int> h(n+1);
vector<int> w(n+1);
int totalw=0;
for (int i = 1; i <= n; i++) cin>>h[i];
for (int i = 1; i <= n; i++) { cin >> w[i]; totalw=(totalw+w[i])%mod; }
int outp=0;
h[0]=0;
for (int i = 1; i <= n; i++)
{
int side1=(clc(totalw%mod)*clc(h[i]%mod));
int side2=(clc(totalw%mod)*clc(h[i-1]%mod));
side1-=side2;
side1%=mod;
outp+=side1;
outp%=mod;
totalw-=w[i];
}
outp%=mod;
cout << outp << "\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... |