답안 #958908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958908 2024-04-07T03:44:19 Z TAhmed33 Fancy Fence (CEOI20_fancyfence) C++
30 / 100
1000 ms 1428 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int TWOINV = 5e8 + 4;
const int MAXN = 1e5 + 25;
int add (int a, int b) {
    a += b; if (a >= MOD) a -= MOD;
    return a;
}
int sub (int a, int b) {
    a -= b; if (a < 0) a += MOD;
    return a;
}
int mul (int a, int b) {
    return (a * 1ll * b) % MOD;
}
int h[MAXN], w[MAXN], n;
int main () {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> h[i];
    for (int i = 1; i <= n; i++) cin >> w[i];
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int x = w[i], y = h[i];
        x = mul(x, mul(x + 1, TWOINV));
        y = mul(y, mul(y + 1, TWOINV));
        ans = add(ans, mul(x, y));
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int x = *min_element(h + i, h + j + 1);
            x = mul(x, mul(x + 1, TWOINV));
            int y = mul(w[i], w[j]);
            ans = add(ans, mul(x, y));
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 155 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 156 ms 468 KB Output is correct
3 Execution timed out 1100 ms 1428 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 348 KB Output is correct
2 Execution timed out 1025 ms 600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 157 ms 492 KB Output is correct
3 Execution timed out 1034 ms 600 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 464 KB Output is correct
2 Correct 155 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 160 ms 348 KB Output is correct
9 Correct 155 ms 344 KB Output is correct
10 Correct 155 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 20 ms 484 KB Output is correct
13 Correct 155 ms 480 KB Output is correct
14 Correct 155 ms 476 KB Output is correct
15 Correct 159 ms 476 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 155 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 155 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 155 ms 480 KB Output is correct
11 Execution timed out 1073 ms 1368 KB Time limit exceeded
12 Halted 0 ms 0 KB -