답안 #1006942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1006942 2024-06-24T10:07:25 Z Hanksburger Fancy Fence (CEOI20_fancyfence) C++17
100 / 100
26 ms 6104 KB
#include <bits/stdc++.h>
using namespace std;
long long h[100005], w[100005], mod=1e9+7, inv2=5e8+4;
vector<pair<long long, long long> > vec;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, cur=0, ans=0;
    cin >> n;
    for (long long i=1; i<=n; i++)
        cin >> h[i];
    for (long long i=1; i<=n; i++)
        cin >> w[i];
    vec.push_back({-1, 0});
    vec.push_back({0, 0});
    for (long long i=1; i<=n+1; i++)
    {
        while (vec[vec.size()-2].first>=h[i])
        {
            long long x=(cur-vec[vec.size()-1].second+mod)%mod*(cur-vec[vec.size()-1].second+1+mod)%mod*inv2%mod;
            long long y=(vec[vec.size()-1].first+vec[vec.size()-2].first+1)%mod*(vec[vec.size()-1].first-vec[vec.size()-2].first+mod)%mod*inv2%mod;
            ans=(ans+x*y)%mod;
            vec.pop_back();
        }
        if (vec[vec.size()-1].first>h[i])
        {
            long long x=(cur-vec[vec.size()-1].second+mod)%mod*(cur-vec[vec.size()-1].second+1+mod)%mod*inv2%mod;
            long long y=(vec[vec.size()-1].first+h[i]+1)%mod*(vec[vec.size()-1].first-h[i]+mod)%mod*inv2%mod;
            ans=(ans+x*y)%mod;
            vec[vec.size()-1].first=h[i];
        }
        else
            vec.push_back({h[i], cur});
        cur=(cur+w[i])%mod;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 7 ms 1628 KB Output is correct
4 Correct 13 ms 3072 KB Output is correct
5 Correct 18 ms 3036 KB Output is correct
6 Correct 14 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 10 ms 1116 KB Output is correct
4 Correct 16 ms 1880 KB Output is correct
5 Correct 17 ms 1884 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 8 ms 1116 KB Output is correct
5 Correct 16 ms 1884 KB Output is correct
6 Correct 17 ms 1952 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 2 ms 1116 KB Output is correct
9 Correct 14 ms 2712 KB Output is correct
10 Correct 26 ms 5836 KB Output is correct
11 Correct 17 ms 6104 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 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 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 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 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 7 ms 1836 KB Output is correct
12 Correct 17 ms 2976 KB Output is correct
13 Correct 13 ms 3164 KB Output is correct
14 Correct 13 ms 3176 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 9 ms 2128 KB Output is correct
18 Correct 17 ms 3816 KB Output is correct
19 Correct 17 ms 3932 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 1116 KB Output is correct
22 Correct 10 ms 2784 KB Output is correct
23 Correct 18 ms 6100 KB Output is correct
24 Correct 18 ms 6104 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 736 KB Output is correct
32 Correct 8 ms 1884 KB Output is correct
33 Correct 8 ms 2096 KB Output is correct
34 Correct 15 ms 3676 KB Output is correct
35 Correct 15 ms 3776 KB Output is correct
36 Correct 18 ms 3932 KB Output is correct
37 Correct 17 ms 3932 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 15 ms 3808 KB Output is correct
40 Correct 15 ms 3932 KB Output is correct
41 Correct 14 ms 4188 KB Output is correct
42 Correct 16 ms 5044 KB Output is correct