304 | 2021-08-30 10:24:07 | Valaki2 | Fancy Fence | cpp14 | Wrong answer 13/100 | 41ms | 38256 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const ll mod = 1e9 + 7;
void solve() {
ll n;
cin >> n;
vector<ll> height(n, 0ll);
vector<ll> width(n, 0ll);
for(ll &x : height) cin >> x;
for(ll &x : width) cin >> x;
ll overall_width = 0;
ll current_width = 0;
ll ans = 0;
height.pb(1ll);
width.pb(0ll);
for(ll i = 0; i <= n; ++i) {
overall_width += width[i];
overall_width %= mod;
if(height[i] == 2) {
current_width += width[i];
current_width %= mod;
} else {
ans += (current_width * (current_width + 1)) / 2;
ans %= mod;
current_width = 0;
}
}
ans *= 2;
ans %= mod;
ans += (overall_width * (overall_width + 1)) / 2;
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 | 2ms | 1812 KiB | ||||
2 | Wrong answer | 2ms | 1972 KiB | ||||
subtask2 | 0/12 | ||||||
3 | Wrong answer | 1ms | 1888 KiB | ||||
4 | Wrong answer | 1ms | 1888 KiB | ||||
5 | Wrong answer | 1ms | 1892 KiB | ||||
6 | Wrong answer | 1ms | 1900 KiB | ||||
7 | Wrong answer | 1ms | 1904 KiB | ||||
subtask3 | 13/13 | ||||||
8 | Accepted | 1ms | 1948 KiB | ||||
9 | Accepted | 17ms | 4752 KiB | ||||
10 | Accepted | 27ms | 8144 KiB | ||||
11 | Accepted | 39ms | 9304 KiB | ||||
12 | Accepted | 24ms | 10480 KiB | ||||
subtask4 | 0/15 | ||||||
13 | Wrong answer | 1ms | 6052 KiB | ||||
14 | Wrong answer | 4ms | 6816 KiB | ||||
15 | Wrong answer | 23ms | 9524 KiB | ||||
16 | Wrong answer | 30ms | 13604 KiB | ||||
17 | Wrong answer | 35ms | 15680 KiB | ||||
subtask5 | 0/15 | ||||||
18 | Wrong answer | 2ms | 11244 KiB | ||||
19 | Wrong answer | 4ms | 12012 KiB | ||||
20 | Wrong answer | 16ms | 14712 KiB | ||||
21 | Wrong answer | 29ms | 18804 KiB | ||||
22 | Wrong answer | 30ms | 20652 KiB | ||||
subtask6 | 0/18 | ||||||
23 | Wrong answer | 1ms | 16180 KiB | ||||
24 | Wrong answer | 2ms | 16208 KiB | ||||
25 | Wrong answer | 2ms | 16240 KiB | ||||
26 | Wrong answer | 1ms | 16260 KiB | ||||
27 | Wrong answer | 1ms | 16276 KiB | ||||
subtask7 | 0/27 | ||||||
28 | Wrong answer | 4ms | 17048 KiB | ||||
29 | Wrong answer | 4ms | 17240 KiB | ||||
30 | Wrong answer | 24ms | 19852 KiB | ||||
31 | Wrong answer | 16ms | 20820 KiB | ||||
32 | Wrong answer | 30ms | 24776 KiB | ||||
33 | Wrong answer | 27ms | 26520 KiB | ||||
34 | Wrong answer | 30ms | 28404 KiB | ||||
35 | Wrong answer | 30ms | 30400 KiB | ||||
36 | Wrong answer | 1ms | 25888 KiB | ||||
37 | Wrong answer | 41ms | 32408 KiB | ||||
38 | Wrong answer | 30ms | 34248 KiB | ||||
39 | Wrong answer | 32ms | 36200 KiB | ||||
40 | Wrong answer | 29ms | 38256 KiB |