Submission #437622

#TimeUsernameProblemLanguageResultExecution timeMemory
437622shahriarkhanFancy Fence (CEOI20_fancyfence)C++14
13 / 100
37 ms5332 KiB
#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)

fancyfence.cpp: In function 'int main()':
fancyfence.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n) ;
      |     ~~~~~^~~~~~~~~
fancyfence.cpp:11:40: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(int i = 1 ; i <= n ; ++i) scanf("%lld",&h[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~~~
fancyfence.cpp:12:40: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(int i = 1 ; i <= n ; ++i) scanf("%lld",&w[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...