Submission #437661

#TimeUsernameProblemLanguageResultExecution timeMemory
437661shahriarkhanFancy Fence (CEOI20_fancyfence)C++14
30 / 100
34 ms3788 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] , 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)

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...