Submission #390427

# Submission time Handle Problem Language Result Execution time Memory
390427 2021-04-16T04:15:45 Z BJoozz Fancy Fence (CEOI20_fancyfence) C++14
42 / 100
28 ms 4428 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);
    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)+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 Incorrect 1 ms 332 KB Output isn't 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 12 ms 2268 KB Output is correct
4 Correct 21 ms 4428 KB Output is correct
5 Correct 23 ms 4052 KB Output is correct
6 Incorrect 26 ms 3912 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
3 Correct 13 ms 1912 KB Output is correct
4 Correct 24 ms 3396 KB Output is correct
5 Correct 27 ms 3404 KB Output is correct
6 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 3 ms 588 KB Output is correct
4 Correct 12 ms 1804 KB Output is correct
5 Correct 24 ms 3348 KB Output is correct
6 Correct 28 ms 3396 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 3 ms 588 KB Output is correct
9 Correct 14 ms 1820 KB Output is correct
10 Correct 24 ms 3396 KB Output is correct
11 Correct 24 ms 3404 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 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 Incorrect 1 ms 332 KB Output isn't correct