# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1116437 | 2024-11-21T16:14:51 Z | jamesbamber | Fancy Fence (CEOI20_fancyfence) | C++17 | 59 ms | 3896 KB |
#include <vector> #include <stack> #include <cassert> #include <iostream> using namespace std; constexpr int MOD = 1e9+7; int main(){ int N; cin >> N; vector<int> L(N), W(N); for(int &x: L) cin >> x; for(int &x: W) cin >> x; L.resize(N+2); W.resize(N+2); for(int i=N; i>0; i--) L[i] = L[i-1]; L[0] = 0; for(int i=N; i>0; i--) W[i] = W[i-1]; W[0] = 0; N+=2; vector<int> pf(N+1); for(int i=0; i<N; i++) pf[i+1] = (pf[i] + W[i])%MOD; auto count_rect = [&](long long l_high, long long l_low, long long w){ long long l = l_high - l_low; return ((w*(w+1)/2)%MOD) * ((l*(l+1)/2)%MOD + l*l_low%MOD)%MOD; }; long long ans = 0; stack<int> st; for(int i=0; i<N; i++){ while(st.size() and L[st.top()] >= L[i]){ int j = st.top(); st.pop(); if(j == 0) break; int l2 = L[j]; int l1 = max(L[i], L[st.top()]); int w = (pf[i] - pf[st.top()+1] + MOD)%MOD; ans += count_rect(l2, l1, w); ans %= MOD; } st.push(i); } assert(st.size() == 1); cout << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 440 KB | Output is correct |
4 | Correct | 1 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 504 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 19 ms | 1480 KB | Output is correct |
4 | Correct | 35 ms | 2752 KB | Output is correct |
5 | Correct | 36 ms | 2752 KB | Output is correct |
6 | Correct | 36 ms | 2760 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 6 ms | 592 KB | Output is correct |
3 | Correct | 26 ms | 1916 KB | Output is correct |
4 | Correct | 51 ms | 3548 KB | Output is correct |
5 | Correct | 53 ms | 3640 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 2 ms | 484 KB | Output is correct |
3 | Correct | 6 ms | 592 KB | Output is correct |
4 | Correct | 26 ms | 1980 KB | Output is correct |
5 | Correct | 52 ms | 3540 KB | Output is correct |
6 | Correct | 57 ms | 3628 KB | Output is correct |
7 | Correct | 2 ms | 336 KB | Output is correct |
8 | Correct | 6 ms | 592 KB | Output is correct |
9 | Correct | 27 ms | 2076 KB | Output is correct |
10 | Correct | 52 ms | 3640 KB | Output is correct |
11 | Correct | 55 ms | 3896 KB | Output is correct |
12 | Correct | 1 ms | 336 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 2 ms | 508 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 1 ms | 508 KB | Output is correct |
5 | Correct | 1 ms | 516 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 2 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 336 KB | Output is correct |
11 | Correct | 1 ms | 336 KB | Output is correct |
12 | Correct | 1 ms | 452 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 336 KB | Output is correct |
15 | Correct | 2 ms | 448 KB | Output is correct |
16 | Correct | 1 ms | 572 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
2 | Correct | 1 ms | 336 KB | Output is correct |
3 | Correct | 1 ms | 336 KB | Output is correct |
4 | Correct | 2 ms | 336 KB | Output is correct |
5 | Correct | 1 ms | 336 KB | Output is correct |
6 | Correct | 1 ms | 336 KB | Output is correct |
7 | Correct | 1 ms | 336 KB | Output is correct |
8 | Correct | 1 ms | 336 KB | Output is correct |
9 | Correct | 1 ms | 336 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 20 ms | 1480 KB | Output is correct |
12 | Correct | 37 ms | 2752 KB | Output is correct |
13 | Correct | 36 ms | 2772 KB | Output is correct |
14 | Correct | 35 ms | 2760 KB | Output is correct |
15 | Correct | 1 ms | 336 KB | Output is correct |
16 | Correct | 7 ms | 592 KB | Output is correct |
17 | Correct | 27 ms | 2004 KB | Output is correct |
18 | Correct | 55 ms | 3496 KB | Output is correct |
19 | Correct | 57 ms | 3640 KB | Output is correct |
20 | Correct | 1 ms | 336 KB | Output is correct |
21 | Correct | 6 ms | 712 KB | Output is correct |
22 | Correct | 28 ms | 1944 KB | Output is correct |
23 | Correct | 52 ms | 3636 KB | Output is correct |
24 | Correct | 54 ms | 3744 KB | Output is correct |
25 | Correct | 1 ms | 336 KB | Output is correct |
26 | Correct | 1 ms | 336 KB | Output is correct |
27 | Correct | 1 ms | 336 KB | Output is correct |
28 | Correct | 2 ms | 336 KB | Output is correct |
29 | Correct | 2 ms | 336 KB | Output is correct |
30 | Correct | 6 ms | 708 KB | Output is correct |
31 | Correct | 7 ms | 592 KB | Output is correct |
32 | Correct | 29 ms | 1948 KB | Output is correct |
33 | Correct | 27 ms | 1992 KB | Output is correct |
34 | Correct | 51 ms | 3364 KB | Output is correct |
35 | Correct | 51 ms | 3240 KB | Output is correct |
36 | Correct | 59 ms | 3520 KB | Output is correct |
37 | Correct | 53 ms | 3504 KB | Output is correct |
38 | Correct | 1 ms | 336 KB | Output is correct |
39 | Correct | 57 ms | 3520 KB | Output is correct |
40 | Correct | 58 ms | 3540 KB | Output is correct |
41 | Correct | 51 ms | 3520 KB | Output is correct |
42 | Correct | 54 ms | 3640 KB | Output is correct |