Submission #1101170

#TimeUsernameProblemLanguageResultExecution timeMemory
1101170vladiliusFancy Fence (CEOI20_fancyfence)C++17
30 / 100
1072 ms1620 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second const int mod = 1e9 + 7; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> h(n + 1); for (int i = 1; i <= n; i++){ cin>>h[i]; } vector<int> w(n + 1); for (int i = 1; i <= n; i++){ cin>>w[i]; } ll out = 0; for (int i = 1; i <= n; i++){ out += (((1LL * w[i] * (w[i] + 1) / 2) % mod) * ((1LL * h[i] * (h[i] + 1) / 2) % mod)) % mod; int x = h[i]; for (int j = i + 1; j <= n; j++){ x = min(x, h[j]); out += (((1LL * w[i] * w[j]) % mod) * ((1LL * x * (x + 1) / 2) % mod)) % mod; } out %= mod; } cout<<out<<"\n"; }
#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...