Submission #906423

#TimeUsernameProblemLanguageResultExecution timeMemory
906423LudisseyFancy Fence (CEOI20_fancyfence)C++14
15 / 100
22 ms1884 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n,m; int mod=1e9+7; int clc(int x) { return (((x*(x+1)))/(long long)2)%mod; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; vector<int> h(n); vector<int> w(n); int totalw=0; for (int i = 0; i < n; i++) cin>>h[i]; for (int i = 0; i < n; i++) { cin >> w[i]; totalw=(totalw+w[i])%mod; } int outp=0; for (int i = 0; i < n; i++) { int lasth=0; if(i>0) lasth=h[i-1]; outp+=(clc(totalw%mod)*clc(h[i]%mod))%mod-(clc(totalw%mod)*clc(lasth%mod))%mod; outp%=mod; totalw-=w[i]; } outp%=mod; cout << outp << "\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...