# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303328 | Ruxandra985 | Fancy Fence (CEOI20_fancyfence) | C++14 | 1 ms | 384 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>
#define MOD 1000000007
#define DIMN 100010
using namespace std;
int h[DIMN] , w[DIMN] , st[DIMN];
long long spw[DIMN];
long long rectangles (int x , int y){
return (((1LL * x * (x + 1) / 2))%MOD * ((1LL * y * (y + 1) / 2)%MOD))%MOD;
}
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , elem = 0;
long long sol = 0 , lat;
fscanf (fin,"%d",&n);
for (i = 1 ; i <= n ; i++)
fscanf (fin,"%d",&h[i]);
for (i = 1 ; i <= n ; i++){
fscanf (fin,"%d",&w[i]);
spw[i] = w[i] + spw[i - 1];
}
h[n + 1] = 0; /// turn fictiv inaltime ft mica
w[n + 1] = 0;
spw[n + 1] = spw[n];
n++;
elem = 0;
for (i = 1 ; i <= n ; i++){
while (elem && h[i] < h[st[elem]]){
/// i il scoate pe st[elem]
lat = spw[i - 1] - spw[st[elem - 1]];
sol = (sol + rectangles(h[st[elem]] , lat) - rectangles (max(h[st[elem - 1]] , h[i]) , lat))%MOD;
elem--;
}
st[++elem] = i;
}
sol = ((sol + MOD)%MOD);
fprintf (fout,"%lld",sol);
return 0;
}
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... |