# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959873 | penguin133 | Fancy Fence (CEOI20_fancyfence) | C++17 | 5 ms | 4696 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pi pair <int, int>
#define pii pair <int, pi>
int n, H[100005], W[100005], P[100005];
stack <pi> s;
int lst[105];
const int mod = 1e9 + 7;
void solve(){
cin >> n;
for(int i = 1; i <= n; i++)cin >> H[i];
for(int i = 1; i <= n; i++)cin >> W[i];
s.push({0, 0});
int ans = 0;
for(int i = 1; i <= n; i++){
P[i] = P[i - 1] + W[i];
for(int j = H[i] + 1; j <= 100; j++)lst[j] = P[i];
for(int j = 1; j <= H[i]; j++){
ans += j * W[i] % mod * (P[i - 1] - lst[j]) % mod;
ans %= mod;
int a = W[i] * (W[i] + 1) / 2;
a %= mod;
a *=j; a %= mod;
ans += a; ans %= mod;
}
//cout << ans << '\n';
}
cout << ans;
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int tc = 1;
//cin >> tc;
while(tc--)solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |