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 nmax 10000
#define mod 1000000007
int w[nmax], h[nmax];
int comb2( int x ) {
long long rez = 0;
rez = rez + x + ((long long) x - 1) * x / 2;
return rez % mod;
}
int main() {
int i, j, n, minn;
long long rez = 0;
cin >> n;
for( i = 0; i < n; i++ )
cin >> h[i];
for( i = 0; i < n; i++ )
cin >> w[i];
for( i = 0; i < n; i++ ) {
minn = w[i];
rez = ( rez + comb2(w[i] ) * comb2(h[i] ) ) % mod;
//cout << rez << " ";
for( j = i + 1; j < n; j++ ) {
minn = min( minn, w[j] );
rez = ( rez + w[i] * w[j] * comb2( minn ) ) % mod;
//cout << rez << " ";
}
//cout << "\n";
}
cout << rez;
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... |