Submission #405209

#TimeUsernameProblemLanguageResultExecution timeMemory
405209varungoyalbitsFancy Fence (CEOI20_fancyfence)C++17
30 / 100
1088 ms1988 KiB
/* Problem Link:https://oj.uz/problem/view/CEOI20_fancyfence Author: varungoyalbits */ #include <bits/stdc++.h> using namespace std; long long sumTillN(const long long N,const long long mod) { return ((N*(N+1))/2)%mod; } long long subTask6() { int n; cin>>n; vector<long long>h(n); vector<long long>w(n); long long mod=1e9+7; for(int i=0;i<n;i++) { cin>>h[i]; } for(int i=0;i<n;i++) { cin>>w[i]; } long long ans=0; for(int i=0;i<n;i++) { long long val=sumTillN(h[i],mod); val=(val*sumTillN(w[i],mod))%mod; ans=(ans+val)%mod; long long mn=h[i]; for(int j=i-1;j>=0;j--) { mn=min(mn,h[j]); val=sumTillN(mn,mod); val=(val*((w[i]*w[j])%mod))%mod; ans=(ans+val)%mod; } } return ans; } int main() { cout<<subTask6()<<"\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...