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 <iostream>
using namespace std;
#define int long long
signed main()
{
int n; int h[200005]; int w[200005];
cin>>n;
for(int i=1; i<=n; i++){cin>>h[i];}
for(int i=1; i<=n; i++){cin>>w[i];}
int ans=0; int p=1e9+7;
for(int i=1; i<=n; i++){
ans += (w[i] * (w[i]+1) / 2 % p) % p * (h[i] * (h[i]+1) / 2 % p) % p; ans %= p;
}
for(int i=1; i<n; i++){
int mn=h[i];
for(int j=i+1; j<=n; j++){
mn=min(mn, h[j]);
ans += w[i] * w[j] % p * (mn * (mn+1) / 2 % p) % p; ans %= p;
}
}
cout<<ans;
}
# | 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... |