# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437661 | shahriarkhan | Fancy Fence (CEOI20_fancyfence) | C++14 | 34 ms | 3788 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] , ans = 0 , suf = 0 ;
for(int i = 1 ; i <= n ; ++i) scanf("%lld",&h[i]) ;
for(int i = 1 ; i <= n ; ++i) scanf("%lld",&w[i]) ;
h[0] = 0 ;
for(int i = n ; i >= 1 ; --i)
{
suf = (suf + w[i])%mod ;
long long extra = ((h[i]*(h[i]+1))/2)%mod ;
extra = ((extra - ((h[i-1]*(h[i-1]+1))/2)%mod) + mod)%mod ;
long long extra2 = ((suf*(suf+1))/2)%mod ;
ans = (ans + ((extra*extra2)%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... |