Submission #701489

#TimeUsernameProblemLanguageResultExecution timeMemory
701489PCTprobabilityFancy Fence (CEOI20_fancyfence)C++17
30 / 100
6 ms468 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1000000007; int main(){ ll n; cin>>n; assert(n<=1000); vector<ll> a(n),b(n); for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<n;i++) cin>>b[i]; ll ans=0; for(int i=0;i<n;i++) (ans+=((b[i]*(b[i]+1))/2%mod)*((a[i]*(a[i]+1)/2)%mod))%=mod; ans%=mod; for(int i=0;i<n;i++){ ll x=a[i]; for(int j=i+1;j<n;j++){ x=min(x,a[j]); ans+=(x*(x+1)/2%mod)*b[i]%mod*b[j]%mod; ans%=mod; } } cout<<ans<<endl; }
#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...