3052021-08-30 10:25:44Valaki2Fancy Fencecpp14Wrong answer 13/10041ms30836 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
1Accepted2ms1788 KiB
2Wrong answer2ms1976 KiB
subtask20/12
3Wrong answer1ms1940 KiB
4Wrong answer1ms1944 KiB
5Wrong answer1ms1956 KiB
6Wrong answer1ms1960 KiB
7Wrong answer1ms1960 KiB
subtask313/13
8Accepted2ms2008 KiB
9Accepted12ms4864 KiB
10Accepted23ms8196 KiB
11Accepted23ms9408 KiB
12Accepted23ms10572 KiB
subtask40/15
13Wrong answer1ms6128 KiB
14Wrong answer4ms6744 KiB
15Wrong answer14ms9536 KiB
16Wrong answer28ms13712 KiB
17Wrong answer30ms15696 KiB
subtask50/15
18Wrong answer1ms11304 KiB
19Wrong answer4ms11912 KiB
20Wrong answer16ms14756 KiB
21Wrong answer28ms18744 KiB
22Wrong answer28ms20636 KiB
subtask60/18
23Wrong answer1ms16196 KiB
24Wrong answer1ms16220 KiB
25Wrong answer2ms16276 KiB
26Wrong answer2ms16280 KiB
27Wrong answer1ms16316 KiB
subtask70/27
28Wrong answer4ms17032 KiB
29Wrong answer4ms17212 KiB
30Wrong answer17ms19832 KiB
31Wrong answer17ms20768 KiB
32Wrong answer28ms24784 KiB
33Wrong answer41ms26516 KiB
34Wrong answer32ms28428 KiB
35Wrong answer28ms30396 KiB
36Wrong answer1ms25848 KiB
37Wrong answer28ms30836 KiB
38Wrong answer30ms30836 KiB
39Wrong answer32ms30836 KiB
40Wrong answer29ms30836 KiB