3062021-08-30 10:39:11Valaki2Fancy Fencecpp14Wrong answer 0/10032ms29704 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1804 KiB
2Wrong answer2ms1808 KiB
subtask20/12
3Wrong answer1ms1868 KiB
4Wrong answer1ms1868 KiB
5Wrong answer1ms1876 KiB
6Wrong answer1ms1884 KiB
7Wrong answer1ms1888 KiB
subtask30/13
8Wrong answer1ms1904 KiB
9Wrong answer13ms3772 KiB
10Wrong answer28ms6564 KiB
11Wrong answer32ms7776 KiB
12Wrong answer24ms8888 KiB
subtask40/15
13Wrong answer1ms5996 KiB
14Wrong answer4ms6404 KiB
15Wrong answer16ms8480 KiB
16Wrong answer30ms12004 KiB
17Wrong answer28ms14132 KiB
subtask50/15
18Wrong answer2ms11172 KiB
19Wrong answer4ms11576 KiB
20Wrong answer14ms13656 KiB
21Wrong answer27ms17084 KiB
22Wrong answer29ms19092 KiB
subtask60/18
23Wrong answer1ms16112 KiB
24Wrong answer1ms16140 KiB
25Wrong answer1ms16152 KiB
26Wrong answer2ms16168 KiB
27Wrong answer1ms16192 KiB
subtask70/27
28Wrong answer4ms16600 KiB
29Wrong answer4ms16788 KiB
30Wrong answer14ms18328 KiB
31Wrong answer14ms18364 KiB
32Wrong answer28ms19924 KiB
33Wrong answer27ms19924 KiB
34Wrong answer28ms19924 KiB
35Wrong answer28ms21844 KiB
36Wrong answer1ms18952 KiB
37Wrong answer29ms23800 KiB
38Wrong answer28ms25752 KiB
39Wrong answer32ms27700 KiB
40Wrong answer28ms29704 KiB