# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
303339 | 2020-09-20T08:20:45 Z | Ruxandra985 | Fancy Fence (CEOI20_fancyfence) | C++14 | 42 ms | 5368 KB |
#include <bits/stdc++.h> #define MOD 1000000007 #define DIMN 100010 using namespace std; long long h[DIMN] , w[DIMN] , st[DIMN]; long long spw[DIMN]; long long rectangles (long long x , long long y){ x %= MOD; y %= MOD; return ( ( (x * (x + 1) / 2)%MOD ) * ( (y * (y + 1) / 2)%MOD ) )%MOD; } int main() { FILE *fin = stdin; FILE *fout = stdout; long long n , i , elem = 0; long long sol = 0 , lat; fscanf (fin,"%lld",&n); for (i = 1 ; i <= n ; i++) fscanf (fin,"%lld",&h[i]); for (i = 1 ; i <= n ; i++){ fscanf (fin,"%lld",&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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 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 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 16 ms | 2048 KB | Output is correct |
4 | Correct | 32 ms | 3872 KB | Output is correct |
5 | Correct | 32 ms | 3832 KB | Output is correct |
6 | Correct | 32 ms | 3840 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 4 ms | 512 KB | Output is correct |
3 | Correct | 19 ms | 1536 KB | Output is correct |
4 | Correct | 36 ms | 2724 KB | Output is correct |
5 | Correct | 36 ms | 2680 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 4 ms | 800 KB | Output is correct |
4 | Correct | 19 ms | 2432 KB | Output is correct |
5 | Correct | 37 ms | 4600 KB | Output is correct |
6 | Correct | 37 ms | 4728 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 896 KB | Output is correct |
9 | Correct | 19 ms | 2688 KB | Output is correct |
10 | Correct | 39 ms | 5240 KB | Output is correct |
11 | Correct | 39 ms | 5368 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 1 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 1 ms | 416 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 0 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 1 ms | 384 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 1 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 17 ms | 2048 KB | Output is correct |
12 | Correct | 32 ms | 3832 KB | Output is correct |
13 | Correct | 32 ms | 3832 KB | Output is correct |
14 | Correct | 32 ms | 3832 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 4 ms | 768 KB | Output is correct |
17 | Correct | 19 ms | 2432 KB | Output is correct |
18 | Correct | 37 ms | 4600 KB | Output is correct |
19 | Correct | 37 ms | 4728 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 896 KB | Output is correct |
22 | Correct | 22 ms | 2680 KB | Output is correct |
23 | Correct | 39 ms | 5240 KB | Output is correct |
24 | Correct | 39 ms | 5368 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 772 KB | Output is correct |
31 | Correct | 5 ms | 768 KB | Output is correct |
32 | Correct | 19 ms | 2432 KB | Output is correct |
33 | Correct | 21 ms | 2432 KB | Output is correct |
34 | Correct | 39 ms | 4344 KB | Output is correct |
35 | Correct | 36 ms | 4344 KB | Output is correct |
36 | Correct | 42 ms | 4600 KB | Output is correct |
37 | Correct | 41 ms | 4600 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 40 ms | 4600 KB | Output is correct |
40 | Correct | 39 ms | 4600 KB | Output is correct |
41 | Correct | 39 ms | 4728 KB | Output is correct |
42 | Correct | 39 ms | 4984 KB | Output is correct |