3042021-08-30 10:24:07Valaki2Fancy Fencecpp14Wrong answer 13/10041ms38256 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted2ms1812 KiB
2Wrong answer2ms1972 KiB
subtask20/12
3Wrong answer1ms1888 KiB
4Wrong answer1ms1888 KiB
5Wrong answer1ms1892 KiB
6Wrong answer1ms1900 KiB
7Wrong answer1ms1904 KiB
subtask313/13
8Accepted1ms1948 KiB
9Accepted17ms4752 KiB
10Accepted27ms8144 KiB
11Accepted39ms9304 KiB
12Accepted24ms10480 KiB
subtask40/15
13Wrong answer1ms6052 KiB
14Wrong answer4ms6816 KiB
15Wrong answer23ms9524 KiB
16Wrong answer30ms13604 KiB
17Wrong answer35ms15680 KiB
subtask50/15
18Wrong answer2ms11244 KiB
19Wrong answer4ms12012 KiB
20Wrong answer16ms14712 KiB
21Wrong answer29ms18804 KiB
22Wrong answer30ms20652 KiB
subtask60/18
23Wrong answer1ms16180 KiB
24Wrong answer2ms16208 KiB
25Wrong answer2ms16240 KiB
26Wrong answer1ms16260 KiB
27Wrong answer1ms16276 KiB
subtask70/27
28Wrong answer4ms17048 KiB
29Wrong answer4ms17240 KiB
30Wrong answer24ms19852 KiB
31Wrong answer16ms20820 KiB
32Wrong answer30ms24776 KiB
33Wrong answer27ms26520 KiB
34Wrong answer30ms28404 KiB
35Wrong answer30ms30400 KiB
36Wrong answer1ms25888 KiB
37Wrong answer41ms32408 KiB
38Wrong answer30ms34248 KiB
39Wrong answer32ms36200 KiB
40Wrong answer29ms38256 KiB