# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437622 | shahriarkhan | Fancy Fence (CEOI20_fancyfence) | C++14 | 37 ms | 5332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std ;
const long long mod = 1e9 + 7 ;
int main()
{
int n ;
scanf("%d",&n) ;
long long h[n+1] , w[n+1] , dp[n+1][3] , ans = 0 ;
for(int i = 1 ; i <= n ; ++i) scanf("%lld",&h[i]) ;
for(int i = 1 ; i <= n ; ++i) scanf("%lld",&w[i]) ;
for(int i = 0 ; i <= n ; ++i)
{
dp[i][1] = 0 , dp[i][2] = 0 ;
}
for(int i = 1 ; i <= n ; ++i)
{
for(int j = 1 ; j <= h[i] ; ++j)
{
dp[i][j] = (dp[i-1][j] + w[i])%mod ;
}
if(h[i]==1)
{
ans = (ans + (dp[i-1][2]*(dp[i-1][2]+1))%mod)%mod ;
}
}
ans = (ans + ((dp[n][1]*(dp[n][1]+1))/2)%mod)%mod ;
ans = (ans + (dp[n][2]*(dp[n][2]+1))%mod)%mod ;
printf("%lld\n",ans) ;
return 0 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |