#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
int r[N][3];
int w[N];
int h[N];
int mod = 1e9 + 7;
signed main(){
int n;
cin>>n;
for (int i=1;i<=n;i++)
cin>>h[i];
int ans = 0;
for (int i=1;i<=n;i++){
cin>>w[i];
int a = (w[i]*(w[i]+1))/2;
a = a % mod;
ans += a;
ans %= mod;
if (h[i]==2)
ans += 2*a;
ans %= mod;
}
for (int i=n;i>=1;i--){
for (int j=1;j<=h[i];j++){
r[i][j] = r[i+1][j];
ans += (r[i][j]*j)%mod;
ans %= mod;
r[i][j] = r[i+1][j] + w[i];
r[i][j] %= mod;
// cout<<"At "<<i<<" "<<j<<" added "<<r[i][j]*j<<endl;
}
}
cout<<ans<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
9 ms |
8028 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
10 ms |
8056 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Runtime error |
11 ms |
8080 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Runtime error |
9 ms |
8036 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
9 ms |
8028 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |