답안 #390422

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
390422 2021-04-16T04:11:21 Z BJoozz Fancy Fence (CEOI20_fancyfence) C++14
30 / 100
101 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(x))%=mod;
        D[++top]=i;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 336 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 9 ms 588 KB Output is correct
3 Correct 48 ms 1792 KB Output is correct
4 Correct 84 ms 3392 KB Output is correct
5 Correct 89 ms 3392 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 336 KB Output is correct
3 Correct 9 ms 588 KB Output is correct
4 Correct 44 ms 1784 KB Output is correct
5 Correct 101 ms 3356 KB Output is correct
6 Correct 89 ms 3396 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 9 ms 620 KB Output is correct
9 Correct 44 ms 1796 KB Output is correct
10 Correct 82 ms 3292 KB Output is correct
11 Correct 86 ms 3332 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 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct