답안 #701508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
701508 2023-02-21T11:33:27 Z Cyanmond Fancy Fence (CEOI20_fancyfence) C++17
30 / 100
75 ms 2004 KB
#include <bits/stdc++.h>

using i64 = long long;
constexpr i64 mod = 1000000007;

i64 add(i64 a, i64 b) {
    return (a + b) % mod;
}
i64 sub(i64 a, i64 b) {
    return (a + mod - b) % mod;
}
i64 mul(i64 a, i64 b) {
    return (a * b) % mod;
}
void eadd(i64 &a, i64 b) {
    a = add(a, b);
}
void esub(i64 &a, i64 b) {
    a = sub(a, b);
}
void emul(i64 &a, i64 b) {
    a = mul(a, b);
}

i64 calcPaint(i64 x, i64 y) {
    return mul((1 + x) * x / 2 % mod, (1 + y) * y / 2 % mod);
}

int main() {
    int N;
    std::cin >> N;
    std::vector<i64> H(N), W(N);
    for (auto &e : H) {
        std::cin >> e;
    }
    for (auto &e : W) {
        std::cin >> e;
    }

    if (std::all_of(H.begin(), H.end(), [&](auto x) {
        return x == H[0];
    })) {
        // subtask 4
        i64 X = H[0], Y = std::accumulate(W.begin(), W.end(), 0ll) % mod;
        std::cout << calcPaint(X, Y) << std::endl;
        return 0;
    }
    bool isSubtask5 = true;
    for (int i = 1; i < N; ++i) {
        if (H[i] < H[i - 1]) {
            isSubtask5 = false;
        }
    }
    if (isSubtask5) {
        i64 wSum = 0, answer = 0;
        for (int i = N - 1; i >= 0; --i) {
            i64 a = calcPaint(H[i], wSum + W[i]), b = calcPaint(H[i], wSum);
            esub(a, b);
            eadd(answer, a);
            eadd(wSum, W[i]);
        }
        std::cout << answer << std::endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 38 ms 1084 KB Output is correct
4 Correct 71 ms 1876 KB Output is correct
5 Correct 75 ms 1876 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 7 ms 340 KB Output is correct
4 Correct 37 ms 980 KB Output is correct
5 Correct 70 ms 1852 KB Output is correct
6 Correct 75 ms 1856 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 8 ms 468 KB Output is correct
9 Correct 37 ms 1108 KB Output is correct
10 Correct 67 ms 2004 KB Output is correct
11 Correct 70 ms 2004 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -