Submission #1006898

# Submission time Handle Problem Language Result Execution time Memory
1006898 2024-06-24T09:38:53 Z Hanksburger Fancy Fence (CEOI20_fancyfence) C++17
27 / 100
22 ms 3932 KB
#include <bits/stdc++.h>
using namespace std;
long long h[100005], w[100005], mod=1e9+7;
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)*(cur-vec[vec.size()-1].second+1+mod)/2%mod;
            long long y=(vec[vec.size()-1].first+vec[vec.size()-2].first+1)*(vec[vec.size()-1].first-vec[vec.size()-2].first)/2%mod;
            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)*(cur-vec[vec.size()-1].second+1+mod)/2%mod;
            long long y=(vec[vec.size()-1].first+h[i]+1)*(vec[vec.size()-1].first-h[i])/2%mod;
            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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 8 ms 1984 KB Output is correct
4 Correct 16 ms 3932 KB Output is correct
5 Correct 21 ms 3864 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 2140 KB Output is correct
5 Correct 19 ms 3932 KB Output is correct
6 Correct 22 ms 3912 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -