#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;
}
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
3 ms |
468 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Incorrect |
3 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
3 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |