# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
558356 | 2022-05-07T07:17:01 Z | Stickfish | Fancy Fence (CEOI20_fancyfence) | C++17 | 112 ms | 8528 KB |
#include <iostream> #include <vector> using namespace std; using ll = long long; const int MAXN = 1e5 + 123; const ll INF = 1e18 + 132; const ll MOD = 1000000007; pair<ll, ll> rsz[MAXN]; ll choose_2(ll x) { x %= MOD; return x * (x - 1) / 2 % MOD; } signed main() { int n; cin >> n; for (int i = 0; i < n; ++i) cin >> rsz[i].second; for (int i = 0; i < n; ++i) cin >> rsz[i].first; ++n; ll ans = 0; vector<pair<ll, ll>> stck; stck.push_back({0, -1}); ll curx = 0; for (int i = 0; i < n; ++i) { vector<pair<ll, ll>> rdel; while (stck.back().second >= rsz[i].second) { rdel.push_back(stck.back()); stck.pop_back(); rdel.back().first -= stck.back().first; } for (int j = 1; j < rdel.size(); ++j) rdel[j].first += rdel[j - 1].first; rdel.push_back({INF, rsz[i].second}); for (int j = 0; j + 1 < rdel.size(); ++j) { ll choose_xs = choose_2(rdel[j].first + 1); ll upy = rdel[j].second - rdel[j + 1].second; ll choose_ys = upy * rdel[j + 1].second % MOD + choose_2(upy + 1); ans += choose_xs * choose_ys; ans %= MOD; } curx += rsz[i].first; stck.push_back({curx, rsz[i].second}); } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 31 ms | 1652 KB | Output is correct |
4 | Correct | 59 ms | 3012 KB | Output is correct |
5 | Correct | 60 ms | 3020 KB | Output is correct |
6 | Correct | 59 ms | 2980 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 11 ms | 648 KB | Output is correct |
3 | Correct | 43 ms | 1932 KB | Output is correct |
4 | Correct | 83 ms | 3692 KB | Output is correct |
5 | Correct | 90 ms | 3892 KB | Output is correct |
6 | Correct | 1 ms | 300 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 212 KB | Output is correct |
3 | Correct | 10 ms | 596 KB | Output is correct |
4 | Correct | 47 ms | 1996 KB | Output is correct |
5 | Correct | 82 ms | 3788 KB | Output is correct |
6 | Correct | 91 ms | 3832 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 9 ms | 1108 KB | Output is correct |
9 | Correct | 48 ms | 3088 KB | Output is correct |
10 | Correct | 84 ms | 8216 KB | Output is correct |
11 | Correct | 82 ms | 8528 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 316 KB | Output is correct |
9 | Correct | 2 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 320 KB | Output is correct |
11 | Correct | 1 ms | 308 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 316 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 2 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 308 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 32 ms | 1564 KB | Output is correct |
12 | Correct | 55 ms | 2992 KB | Output is correct |
13 | Correct | 63 ms | 2980 KB | Output is correct |
14 | Correct | 64 ms | 2928 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 9 ms | 596 KB | Output is correct |
17 | Correct | 43 ms | 1964 KB | Output is correct |
18 | Correct | 99 ms | 3744 KB | Output is correct |
19 | Correct | 81 ms | 3872 KB | Output is correct |
20 | Correct | 2 ms | 340 KB | Output is correct |
21 | Correct | 9 ms | 1160 KB | Output is correct |
22 | Correct | 50 ms | 3160 KB | Output is correct |
23 | Correct | 76 ms | 8252 KB | Output is correct |
24 | Correct | 80 ms | 8408 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 2 ms | 292 KB | Output is correct |
27 | Correct | 2 ms | 320 KB | Output is correct |
28 | Correct | 2 ms | 340 KB | Output is correct |
29 | Correct | 2 ms | 320 KB | Output is correct |
30 | Correct | 9 ms | 656 KB | Output is correct |
31 | Correct | 9 ms | 596 KB | Output is correct |
32 | Correct | 38 ms | 1936 KB | Output is correct |
33 | Correct | 41 ms | 1992 KB | Output is correct |
34 | Correct | 82 ms | 3492 KB | Output is correct |
35 | Correct | 81 ms | 3580 KB | Output is correct |
36 | Correct | 91 ms | 3728 KB | Output is correct |
37 | Correct | 112 ms | 3692 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 84 ms | 3716 KB | Output is correct |
40 | Correct | 80 ms | 3700 KB | Output is correct |
41 | Correct | 82 ms | 4360 KB | Output is correct |
42 | Correct | 91 ms | 6032 KB | Output is correct |