Submission #997789

# Submission time Handle Problem Language Result Execution time Memory
997789 2024-06-12T21:56:24 Z ErJ Fancy Fence (CEOI20_fancyfence) C++17
12 / 100
1 ms 348 KB
#include <bits/stdc++.h>
    
using namespace std;
    
#define ll long long
#define vi vector<ll>
#define vp vector<pp>
#define vvi vector<vi>
#define vvp vector<vp>
#define pp pair<ll, ll>
#define inf 1000000000000000
#define rep(i,n) for(ll i = 0; i < n; i++)
#define mod 1000000007


ll get(ll h, ll w){
    return (((h * (h + 1)/ 2) % mod) * ((w * (w + 1) / 2) % mod) % mod);
}

int main(){
    ll n;
    cin >> n;
    vi H(n + 1), W(n + 1);
    rep(i,n){
        cin >> H[i];
    }
    H[n] = 0; W[n] = 0;
    rep(i,n) cin >> W[i];
    vector<pp> q;
    q.push_back({-1, -1});
    ll ans = 0;
    rep(i,n + 1){
        ll akt = 0;
        while(q.back().first >= H[i]){
            pp seclast = q[q.size() - 2];
            if(seclast.first >= H[i]){
                ans += get(q.back().first, q.back().second);
                ans -= get(seclast.first, q.back().second);
                ans %= mod;
                ll www = q.back().second;
                q.pop_back();
                q.back().second += www;
            }else{
                ans += get(q.back().first, q.back().second);
                ans -= get(H[i], q.back().second);
                ans %= mod;
                akt = q.back().second;
                q.pop_back();
            }
        }
        q.push_back({H[i], W[i] + akt});

        
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 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 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -