# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303334 | 2020-09-20T08:18:18 Z | Ruxandra985 | Fancy Fence (CEOI20_fancyfence) | C++14 | 1 ms | 384 KB |
#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 (long long x , long long y){ return ( ( (x * (x + 1) / 2)%MOD ) * ( (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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Incorrect | 1 ms | 384 KB | Output isn't correct |