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;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const int mod = 1e9 + 7;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n; cin>>n;
vector<int> h(n + 1);
for (int i = 1; i <= n; i++){
cin>>h[i];
}
vector<int> w(n + 1);
for (int i = 1; i <= n; i++){
cin>>w[i];
}
ll out = 0;
for (int i = 1; i <= n; i++){
out += ((1LL * w[i] * (w[i] + 1) / 2) % mod * (1LL * h[i] * (h[i] + 1) / 2) % mod) % mod;
int x = h[i];
for (int j = i + 1; j <= n; j++){
x = min(x, h[j]);
out += ((1LL * w[i] * w[j]) % mod * (1LL * x * (x + 1) / 2) % mod) % mod;
}
out %= mod;
}
cout<<out<<"\n";
}
# | 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... |