답안 #390421

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390421 2021-04-16T04:08:35 Z BJoozz Fancy Fence (CEOI20_fancyfence) C++14
30 / 100
88 ms 3396 KB
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define int long long
const int MAX=1e5+3,mod=1e9+7;
int dp[MAX];
void maxx(int &a,int b){if(b>a) a=b;}
void minn(int &a,int b){if(b<a) a=b;}
void PL(int &a,int b){a+=b;if(a>=mod) a-=mod;}
int b[MAX];
int a[MAX];
int D[MAX];
int gs(int x){
    return (x*(x+1)/2)%mod;
}
signed main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans=0;
    int top=0;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        b[i]=b[i-1]+x;
        while(a[i]<a[D[top]]) top--;
        int u=D[top];
        dp[i]=( gs(a[i])*(b[i]-b[u])+dp[u] )%mod;
        (ans+=dp[u]*x+gs(a[i])*gs(b[i]-b[u]))%=mod;
        D[++top]=i;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 10 ms 588 KB Output is correct
3 Correct 44 ms 1836 KB Output is correct
4 Correct 84 ms 3396 KB Output is correct
5 Correct 86 ms 3308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 9 ms 624 KB Output is correct
4 Correct 44 ms 1876 KB Output is correct
5 Correct 87 ms 3332 KB Output is correct
6 Correct 88 ms 3396 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 9 ms 624 KB Output is correct
9 Correct 44 ms 1816 KB Output is correct
10 Correct 82 ms 3316 KB Output is correct
11 Correct 86 ms 3396 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 2 ms 332 KB Output isn't correct