# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
854402 | pliam | Fancy Fence (CEOI20_fancyfence) | C++17 | 122 ms | 262144 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 MAXN 100005
typedef long long ll;
#define MOD (ll)1e9+7
#define INF (ll)2e9
/*
Brute force N^4
*/
int N, L;
ll h[MAXN], w[MAXN];
vector<ll> nh;
int main(){
scanf("%d",&N);
for(int i=0;i<N;i++){
scanf("%lld",&h[i]);
}
for(int i=0;i<N;i++){
scanf("%lld",&w[i]);
for(int j=0;j<w[i];j++){
L++;
nh.push_back(h[i]);
}
}
ll ans=0;
for(int i=0;i<L;i++){
// printf("%lld\n", nh[i]);
for(int j=0; j<=i; j++){
//[j,i], find minimum m and answer is m*(m+1)/2
ll m=INF;
for(int k=j;k<=i;k++){
m = min(m, nh[k]);
}
ans += (m*(m+1))/2LL;
ans %= MOD;
}
}
printf("%lld\n", ans);
}
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... |