답안 #790899

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790899 2023-07-23T09:19:18 Z 12345678 Fancy Fence (CEOI20_fancyfence) C++17
55 / 100
40 ms 8776 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll nx=1e5+5, mod=1e9+7;
ll n, ans, h, w, sm, H[nx], W[nx];
stack<pair<pair<ll, ll>, ll>> s;

ll cal(ll x)
{
    return (x*(x+1)/2)%mod;
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=0; i<n; i++) cin>>H[i];
    for (int i=0; i<n; i++) cin>>W[i];
    for (int i=0; i<n; i++)
    {
        ll h=H[i], w=W[i];
        ans=(ans+(cal(h)*cal(w))%mod)%mod;
        ll sw=0;
        while (!s.empty()&&s.top().first.first>h)
        {
            sw+=s.top().first.second;
            sm=((sm-s.top().second)%mod+mod)%mod;
            s.pop();
        }
        ll tmp=(cal(h)*sw)%mod;
        s.push({{h, sw}, tmp});
        sm=(sm+tmp)%mod;
        ans=(ans+sm*w)%mod;
        tmp=(cal(h)*w)%mod;
        s.push({{h, w}, tmp});
        sm=(sm+tmp)%mod;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 11 ms 2264 KB Output is correct
4 Correct 16 ms 5956 KB Output is correct
5 Correct 17 ms 4008 KB Output is correct
6 Correct 16 ms 2536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 4 ms 1100 KB Output is correct
3 Correct 17 ms 4436 KB Output is correct
4 Correct 20 ms 8632 KB Output is correct
5 Correct 20 ms 8776 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 3 ms 1104 KB Output is correct
4 Correct 16 ms 4400 KB Output is correct
5 Correct 22 ms 8680 KB Output is correct
6 Correct 40 ms 8664 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 3 ms 1108 KB Output is correct
9 Correct 11 ms 4436 KB Output is correct
10 Correct 21 ms 8532 KB Output is correct
11 Correct 23 ms 8632 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -