305 | 2021-08-30 10:25:44 | Valaki2 | Fancy Fence | cpp14 | Wrong answer 13/100 | 41ms | 30836 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 | 1788 KiB | ||||
2 | Wrong answer | 2ms | 1976 KiB | ||||
subtask2 | 0/12 | ||||||
3 | Wrong answer | 1ms | 1940 KiB | ||||
4 | Wrong answer | 1ms | 1944 KiB | ||||
5 | Wrong answer | 1ms | 1956 KiB | ||||
6 | Wrong answer | 1ms | 1960 KiB | ||||
7 | Wrong answer | 1ms | 1960 KiB | ||||
subtask3 | 13/13 | ||||||
8 | Accepted | 2ms | 2008 KiB | ||||
9 | Accepted | 12ms | 4864 KiB | ||||
10 | Accepted | 23ms | 8196 KiB | ||||
11 | Accepted | 23ms | 9408 KiB | ||||
12 | Accepted | 23ms | 10572 KiB | ||||
subtask4 | 0/15 | ||||||
13 | Wrong answer | 1ms | 6128 KiB | ||||
14 | Wrong answer | 4ms | 6744 KiB | ||||
15 | Wrong answer | 14ms | 9536 KiB | ||||
16 | Wrong answer | 28ms | 13712 KiB | ||||
17 | Wrong answer | 30ms | 15696 KiB | ||||
subtask5 | 0/15 | ||||||
18 | Wrong answer | 1ms | 11304 KiB | ||||
19 | Wrong answer | 4ms | 11912 KiB | ||||
20 | Wrong answer | 16ms | 14756 KiB | ||||
21 | Wrong answer | 28ms | 18744 KiB | ||||
22 | Wrong answer | 28ms | 20636 KiB | ||||
subtask6 | 0/18 | ||||||
23 | Wrong answer | 1ms | 16196 KiB | ||||
24 | Wrong answer | 1ms | 16220 KiB | ||||
25 | Wrong answer | 2ms | 16276 KiB | ||||
26 | Wrong answer | 2ms | 16280 KiB | ||||
27 | Wrong answer | 1ms | 16316 KiB | ||||
subtask7 | 0/27 | ||||||
28 | Wrong answer | 4ms | 17032 KiB | ||||
29 | Wrong answer | 4ms | 17212 KiB | ||||
30 | Wrong answer | 17ms | 19832 KiB | ||||
31 | Wrong answer | 17ms | 20768 KiB | ||||
32 | Wrong answer | 28ms | 24784 KiB | ||||
33 | Wrong answer | 41ms | 26516 KiB | ||||
34 | Wrong answer | 32ms | 28428 KiB | ||||
35 | Wrong answer | 28ms | 30396 KiB | ||||
36 | Wrong answer | 1ms | 25848 KiB | ||||
37 | Wrong answer | 28ms | 30836 KiB | ||||
38 | Wrong answer | 30ms | 30836 KiB | ||||
39 | Wrong answer | 32ms | 30836 KiB | ||||
40 | Wrong answer | 29ms | 30836 KiB |