# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1199544 | thewizardman | Fancy Fence (CEOI20_fancyfence) | C++20 | 5 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n, h[100001], w[100001], dp[100001], md = 1e9+7, ans;
vector<pair<ll, ll>> v;
ll bruh(ll a, ll b) {
return ((a * b) / 2ll) % md;
}
int main() {
scanf("%lld", &n);
for (int i = 0; i < n; i++) scanf("%lld", h+i);
for (int i = 0; i < n; i++) scanf("%lld", w+i);
for (int i = 0; i < n; i++) {
while (!v.empty() && v.back().first > h[i]) v.pop_back();
v.push_back({h[i], w[i]});
ll k = 0, asdf = 0;
for (auto it = v.rbegin(); it != v.rend(); it++) {
auto [h, w] = *it;
ans = (ans + bruh(h+1, h) * bruh(w+k+1, w)) % md;
k += w;
// cout << k << ' ' << w << ' ';
}
// ans += asdf;
// cout << asdf << '\n';
}
printf("%lld", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |