306 | 2021-08-30 10:39:11 | Valaki2 | Fancy Fence | cpp14 | Wrong answer 0/100 | 32ms | 29704 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
void solve() {
ll n;
cin >> n;
vector<ll> height(n, 0);
vector<ll> width(n, 0);
for(ll &x : height) cin >> x;
for(ll &x : width) cin >> x;
ll cur_height = 0;
ll cur_width = 0;
ll ans = 0;
for(ll i = n - 1; i >= 0; --i) {
cur_width += width[i];
cur_height = height[i];
ll cur_ans = 1;
cur_ans *= (cur_width * width[i] - ((width[i] * (width[i] - 1)) / 2));
cur_ans %= mod;
cur_ans *= (cur_height * (cur_height + 1)) / 2;
cur_ans %= mod;
ans += cur_ans;
ans %= mod;
}
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1804 KiB | ||||
2 | Wrong answer | 2ms | 1808 KiB | ||||
subtask2 | 0/12 | ||||||
3 | Wrong answer | 1ms | 1868 KiB | ||||
4 | Wrong answer | 1ms | 1868 KiB | ||||
5 | Wrong answer | 1ms | 1876 KiB | ||||
6 | Wrong answer | 1ms | 1884 KiB | ||||
7 | Wrong answer | 1ms | 1888 KiB | ||||
subtask3 | 0/13 | ||||||
8 | Wrong answer | 1ms | 1904 KiB | ||||
9 | Wrong answer | 13ms | 3772 KiB | ||||
10 | Wrong answer | 28ms | 6564 KiB | ||||
11 | Wrong answer | 32ms | 7776 KiB | ||||
12 | Wrong answer | 24ms | 8888 KiB | ||||
subtask4 | 0/15 | ||||||
13 | Wrong answer | 1ms | 5996 KiB | ||||
14 | Wrong answer | 4ms | 6404 KiB | ||||
15 | Wrong answer | 16ms | 8480 KiB | ||||
16 | Wrong answer | 30ms | 12004 KiB | ||||
17 | Wrong answer | 28ms | 14132 KiB | ||||
subtask5 | 0/15 | ||||||
18 | Wrong answer | 2ms | 11172 KiB | ||||
19 | Wrong answer | 4ms | 11576 KiB | ||||
20 | Wrong answer | 14ms | 13656 KiB | ||||
21 | Wrong answer | 27ms | 17084 KiB | ||||
22 | Wrong answer | 29ms | 19092 KiB | ||||
subtask6 | 0/18 | ||||||
23 | Wrong answer | 1ms | 16112 KiB | ||||
24 | Wrong answer | 1ms | 16140 KiB | ||||
25 | Wrong answer | 1ms | 16152 KiB | ||||
26 | Wrong answer | 2ms | 16168 KiB | ||||
27 | Wrong answer | 1ms | 16192 KiB | ||||
subtask7 | 0/27 | ||||||
28 | Wrong answer | 4ms | 16600 KiB | ||||
29 | Wrong answer | 4ms | 16788 KiB | ||||
30 | Wrong answer | 14ms | 18328 KiB | ||||
31 | Wrong answer | 14ms | 18364 KiB | ||||
32 | Wrong answer | 28ms | 19924 KiB | ||||
33 | Wrong answer | 27ms | 19924 KiB | ||||
34 | Wrong answer | 28ms | 19924 KiB | ||||
35 | Wrong answer | 28ms | 21844 KiB | ||||
36 | Wrong answer | 1ms | 18952 KiB | ||||
37 | Wrong answer | 29ms | 23800 KiB | ||||
38 | Wrong answer | 28ms | 25752 KiB | ||||
39 | Wrong answer | 32ms | 27700 KiB | ||||
40 | Wrong answer | 28ms | 29704 KiB |