답안 #1100029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1100029 2024-10-12T13:00:47 Z ocasu Fancy Fence (CEOI20_fancyfence) C++17
12 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
    int n; cin>>n;
    vector<int> h(n), w(n);
    for (int i=0; i<n; i++) cin>>h[i];
    for (int i=0; i<n; i++) cin>>w[i];
    vector<int> sumLeft(n,0), sumRight(n,0);
    stack<int> sL,sR;
    for (int i=0; i<n; i++){
        while (!sL.empty() and h[sL.top()]>h[i]){
            sumLeft[i]+=sumLeft[sL.top()]+w[sL.top()];
            sL.pop();
        }
        sL.push(i);
    }
    for (int i=n-1; i>=0; i--){
        while (!sR.empty() and h[sR.top()]>=h[i]){
            sumRight[i]+=sumRight[sR.top()]+w[sR.top()];
            sR.pop();
        }
        sR.push(i);
    }
    ///rwgrgw
    int ans=0;
    for (int i=0; i<n; i++){
        int hors = sumLeft[i]*sumRight[i] + sumLeft[i]*w[i]+sumRight[i]*w[i] + w[i]*(w[i]-1)/2 + w[i];
        int verts = h[i]*(h[i]-1)/2 + h[i];
        ans+=hors*verts;
    }
    cout<<ans<<'\n';

}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -