Submission #746003

#TimeUsernameProblemLanguageResultExecution timeMemory
746003vjudge1Fancy Fence (CEOI20_fancyfence)C++17
15 / 100
77 ms1832 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mod=1000000007; int f(int wossz, int hossz){ return (((((hossz*(hossz+1)/2)%mod) * wossz)%mod)*(wossz+1)/2)%mod; } int32_t main() { // all hi are equal --> téglalap int s; cin>>s; int h[s]; int w[s]; int wossz = 0; bool teglalap = true; for (int i=0; i<s; i++){ cin >> h[i]; if (h[i] != h[0]) teglalap = false; } int hossz = h[0]; for(int i=0; i<s; i++){ cin>>w[i]; wossz = (w[i] + wossz) % mod; } if (teglalap){ cout << f(wossz, hossz); return 0; } //cout << (((((hossz*(hossz+1)/2)%mod) * wossz)%mod)*(wossz+1)/2)%mod<<"\n"; // --------------- lépcső ----------------- int ans = f(wossz, h[0]); wossz = (wossz - w[0])%mod; for (int i=1; i<s; i++){ ans = (ans + f((wossz+mod)%mod, h[i]))%mod; ans = (ans - f((wossz+mod)%mod, h[i-1]))%mod; wossz = (wossz - w[i])%mod; } ans=(ans+mod)%mod; cout << ans<<"\n"; return 0; }
#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...