Submission #390429

# Submission time Handle Problem Language Result Execution time Memory
390429 2021-04-16T04:21:18 Z BJoozz Fancy Fence (CEOI20_fancyfence) C++14
25 / 100
30 ms 5440 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(){
    ios::sync_with_stdio(0);cin.tie(0);
    //freopen("A.inp","r",stdin);
    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)%mod;
        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)+x*(b[i-1]-b[u])%mod) )%=mod;
        D[++top]=i;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 10 ms 1612 KB Output is correct
4 Correct 21 ms 3252 KB Output is correct
5 Correct 23 ms 2848 KB Output is correct
6 Correct 20 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 592 KB Output is correct
3 Correct 13 ms 1868 KB Output is correct
4 Incorrect 30 ms 3424 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 3 ms 588 KB Output is correct
4 Correct 13 ms 1868 KB Output is correct
5 Incorrect 25 ms 3404 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Incorrect 1 ms 332 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 11 ms 2252 KB Output is correct
12 Correct 21 ms 4420 KB Output is correct
13 Correct 21 ms 4088 KB Output is correct
14 Correct 21 ms 3888 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 3 ms 844 KB Output is correct
17 Correct 13 ms 2764 KB Output is correct
18 Incorrect 29 ms 5440 KB Output isn't correct
19 Halted 0 ms 0 KB -