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;
using ll = long long;
const ll mod = 1000000007;
int main(){
ll n;
cin>>n;
assert(n<=1000);
vector<ll> a(n),b(n);
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n;i++) cin>>b[i];
ll ans=0;
for(int i=0;i<n;i++) (ans+=((b[i]*(b[i]+1))/2%mod)*((a[i]*(a[i]+1)/2)%mod))%=mod;
ans%=mod;
for(int i=0;i<n;i++){
ll x=a[i];
for(int j=i+1;j<n;j++){
x=min(x,a[j]);
ans+=(x*(x+1)/2%mod)*b[i]%mod*b[j]%mod;
ans%=mod;
}
}
cout<<ans<<endl;
}
# | 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... |