#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll solve_rect(ll h, ll w) {
h %= mod;
w %= mod;
ll hc = (h * (h + 1) / 2) % mod;
ll wc = (w * (w + 1) / 2) % mod;
return (hc * wc) % mod;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
vector<ll> hv(n), wv(n);
for (ll& h : hv) cin >> h;
for (ll& w : wv) cin >> w;
ll res = 0ll;
ll w_rem = accumulate(wv.begin(), wv.end(), 0ll);
res += solve_rect(hv[0], w_rem);
/*
ll prev_h = 0ll;
cout << w_rem << endl;
for (int i = 0; i < n; i++) {
int h = hv[i], w = wv[i];
res += solve_rect(h - prev_h, w_rem);
res %= mod;
w_rem -= w;
prev_h = h;
}*/
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
9 ms |
1108 KB |
Output is correct |
4 |
Correct |
18 ms |
1900 KB |
Output is correct |
5 |
Correct |
21 ms |
1876 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |