#include <iostream>
using namespace std;
#define int long long
signed main()
{
int n; int h[200005]; int w[200005];
cin>>n;
for(int i=1; i<=n; i++){cin>>h[i];}
for(int i=1; i<=n; i++){cin>>w[i];}
int ans=0; int p=1e9+7;
for(int i=1; i<=n; i++){
ans += (w[i] * (w[i]+1) / 2 % p) % p * (h[i] * (h[i]+1) / 2 % p) % p; ans %= p;
}
for(int i=1; i<n; i++){
int mn=h[i];
for(int j=i+1; j<=n; j++){
mn=min(mn, h[j]);
ans += w[i] * w[j] % p * (mn * (mn+1) / 2 % p) % p; ans %= p;
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3408 KB |
Output is correct |
2 |
Correct |
9 ms |
3408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3408 KB |
Output is correct |
2 |
Correct |
3 ms |
3364 KB |
Output is correct |
3 |
Correct |
3 ms |
3408 KB |
Output is correct |
4 |
Correct |
3 ms |
3408 KB |
Output is correct |
5 |
Correct |
4 ms |
3408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3408 KB |
Output is correct |
2 |
Correct |
7 ms |
3408 KB |
Output is correct |
3 |
Execution timed out |
1092 ms |
3920 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
3408 KB |
Output is correct |
2 |
Correct |
336 ms |
3836 KB |
Output is correct |
3 |
Execution timed out |
1055 ms |
4432 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3408 KB |
Output is correct |
2 |
Correct |
7 ms |
3572 KB |
Output is correct |
3 |
Correct |
338 ms |
3740 KB |
Output is correct |
4 |
Execution timed out |
1061 ms |
4432 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3408 KB |
Output is correct |
2 |
Correct |
7 ms |
3524 KB |
Output is correct |
3 |
Correct |
3 ms |
3576 KB |
Output is correct |
4 |
Correct |
3 ms |
3508 KB |
Output is correct |
5 |
Correct |
5 ms |
3408 KB |
Output is correct |
6 |
Correct |
4 ms |
3408 KB |
Output is correct |
7 |
Correct |
3 ms |
3408 KB |
Output is correct |
8 |
Correct |
7 ms |
3408 KB |
Output is correct |
9 |
Correct |
7 ms |
3408 KB |
Output is correct |
10 |
Correct |
7 ms |
3408 KB |
Output is correct |
11 |
Correct |
3 ms |
3408 KB |
Output is correct |
12 |
Correct |
4 ms |
3336 KB |
Output is correct |
13 |
Correct |
7 ms |
3408 KB |
Output is correct |
14 |
Correct |
8 ms |
3584 KB |
Output is correct |
15 |
Correct |
9 ms |
3408 KB |
Output is correct |
16 |
Correct |
3 ms |
3408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
3408 KB |
Output is correct |
2 |
Correct |
9 ms |
3408 KB |
Output is correct |
3 |
Correct |
4 ms |
3408 KB |
Output is correct |
4 |
Correct |
7 ms |
3408 KB |
Output is correct |
5 |
Correct |
4 ms |
3408 KB |
Output is correct |
6 |
Correct |
4 ms |
3564 KB |
Output is correct |
7 |
Correct |
3 ms |
3408 KB |
Output is correct |
8 |
Correct |
3 ms |
3408 KB |
Output is correct |
9 |
Correct |
4 ms |
3408 KB |
Output is correct |
10 |
Correct |
7 ms |
3408 KB |
Output is correct |
11 |
Execution timed out |
1094 ms |
3920 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |