답안 #936348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
936348 2024-03-01T16:35:21 Z VMaksimoski008 Fancy Fence (CEOI20_fancyfence) C++14
27 / 100
70 ms 3128 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int inv = 500000004;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;

int32_t main() {
    int n;
    cin >> n;
    set<int> diff;

    vector<int> h(n), w(n);
    for(int &x : h) cin >> x, diff.insert(x);
    for(int &x : w) cin >> x;

    auto f = [&](ll a, ll b) {
        ll p1 = 1ll * a * (a + 1) % mod * inv % mod;
        ll p2 = 1ll * b * (b + 1) % mod * inv % mod;
        return (p1 * p2) % mod;
    };

    if(diff.size() == 1) {
        ll W = 0;
        for(int &x : w) W += x, W %= mod;
        cout << f(W, h[0]) << '\n';
        return 0;
    }

    ll ans = 0;

    for(int i=0; i<n; i++) {
        ll W = 0;
        ll H = h[i];
        for(int j=i; j<n; j++) {
            W += w[j];
            H = min(H, 1ll * h[j]);
            ll res = (f(W, H) - f(H, W-w[i]) + mod - f(H, W-w[j]) + mod + f(H, W-w[i]-w[j])) % mod;
            if(i == j) res = f(W, H);
            ans += res;
            ans %= mod;
        }
    }

    cout << ans << '\n';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 13 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 0 ms 348 KB Output is correct
2 Incorrect 13 ms 452 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 6 ms 348 KB Output is correct
3 Correct 28 ms 828 KB Output is correct
4 Correct 55 ms 1220 KB Output is correct
5 Correct 58 ms 1112 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 6 ms 604 KB Output is correct
4 Correct 28 ms 1628 KB Output is correct
5 Correct 55 ms 3108 KB Output is correct
6 Correct 70 ms 3128 KB Output is correct
7 Incorrect 13 ms 600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 13 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 13 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -