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>
#include <vector>
#include <map>
#include <stack>
using namespace std;
#define int long long
const int mod=1e9+7;
signed main(){
int n;
cin>>n;
vector<int> v(n),h(n);
map<int,int> mp;
for(int& i:h)cin>>i;
for(int& i:v)cin>>i;
long long ans=0;
for(int i=0;i<n;i++){
ans+=(((v[i]*(v[i]+1)/2)%mod)*(h[i]*(h[i]+1)/2)%mod)%mod;
ans%=mod;
int he=h[i];
for(int j=i+1;j<n;j++){
he=min(he,h[j]);
ans+=(((v[j]*(v[i]))%mod)*(he*(he+1)/2)%mod)%mod;
ans%=mod;
}
}
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... |