Submission #945590

#TimeUsernameProblemLanguageResultExecution timeMemory
945590thelegendary08Fancy Fence (CEOI20_fancyfence)C++14
0 / 100
1 ms748 KiB
#include<bits/stdc++.h> #define vi vector<int> #define vll vector<long long int> #define vpii vector<pair<int,int>> #define vpll vector<pair<long long int, long long int>> #define pb push_back #define f0r(i,n) for(int i = 0;i<n;i++) using namespace std; typedef long long int ll; const ll mod = 1e9 + 7; ll ans(ll w, ll h){ return w * (w+1)/2 % mod * h * (h+1)/2 % mod; } ll c2(ll x){ return x * (x+1) / 2 % mod; } int main(){ int n; cin>>n; vll w(n); vll h(n); f0r(i,n)cin>>h[i]; f0r(i,n)cin>>w[i]; ll dp[n+1]; dp[0] = ans(w[0], h[0]); for(int i = 1;i<n;i++){ dp[i] = ((dp[i-1] + ans(w[i], h[i])) % mod + (w[i-1] * w[i] % mod * c2(min(h[i-1], h[i])) % mod)) % mod; } cout<<dp[n-1]; }
#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...