Submission #390418

# Submission time Handle Problem Language Result Execution time Memory
390418 2021-04-16T04:07:42 Z BJoozz Fancy Fence (CEOI20_fancyfence) C++14
30 / 100
100 ms 5444 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]]) D[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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 9 ms 716 KB Output is correct
3 Correct 44 ms 2768 KB Output is correct
4 Correct 87 ms 5304 KB Output is correct
5 Correct 90 ms 5444 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 9 ms 716 KB Output is correct
4 Correct 43 ms 2776 KB Output is correct
5 Correct 87 ms 5292 KB Output is correct
6 Correct 91 ms 5380 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 9 ms 816 KB Output is correct
9 Correct 43 ms 2824 KB Output is correct
10 Correct 85 ms 5376 KB Output is correct
11 Correct 100 ms 5336 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct