# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534864 | mjhmjh1104 | Fancy Fence (CEOI20_fancyfence) | C++17 | 9 ms | 4224 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
const int MOD = 1e9 + 7;
int n, h[1006], w[1006], res, a[1006][1006];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", h + i);
for (int i = 0; i < n; i++) scanf("%d", w + i);
for (int i = 0; i < n; i++) res = (res + 1LL * (1LL * w[i] * (w[i] + 1) / 2 % MOD) * (1LL * h[i] * (h[i] + 1) / 2 % MOD) % MOD) % MOD;
for (int i = 0; i < n; i++) {
a[i][i] = h[i];
for (int j = i + 1; j < n; j++) a[i][j] = min(h[j], a[i][j - 1]);
}
for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) res = (res + 1LL * w[i] * w[j] % MOD * (1LL * a[i][j] * (a[i][j] + 1) / 2 % MOD) % MOD) % MOD;
printf("%d", res);
}
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... |