답안 #787227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
787227 2023-07-18T23:25:18 Z MilosMilutinovic 송신탑 (IOI22_towers) C++17
100 / 100
1735 ms 39416 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int L = 22;
int n, a[N], pl[N], pr[N], ord[N], go_l[N], go_r[N];
bool cmp(int i, int j) { return a[i] < a[j]; }
int mx[N][L], logs[N];
int qmx(int l, int r) {
    if (l > r) return (int) -1e9;
    int k = logs[r - l + 1];
    return max(mx[l][k], mx[r - (1 << k) + 1][k]);
}
void buildST() {
    for (int i = 1; i <= n; i++) mx[i][0] = a[i];
    for (int i = 2; i <= n; i++) logs[i] = logs[i >> 1] + 1;
    for (int j = 1; j < L; j++)
        for (int i = 1; i + (1 << j) <= n + 1; i++)
            mx[i][j] = max(mx[i][j - 1], mx[i + (1 << (j - 1))][j - 1]);
}
const int M = N * L;
int tsz, ls[M], rs[M], sum[M];
void modify(int& v, int p, int tl, int tr, int i, int x) {
    v = ++tsz;
    ls[v] = ls[p];
    rs[v] = rs[p];
    sum[v] = sum[p] + x;
    if (tl == tr) {
        return;
    }
    int mid = tl + tr >> 1;
    if (i <= mid) {
        modify(ls[v], ls[p], tl, mid, i, x);
    } else {
        modify(rs[v], rs[p], mid + 1, tr, i, x);
    }
}
int query(int v, int tl, int tr, int ql, int qr) {
    if (tl > tr || tl > qr || tr < ql) {
        return 0;
    }
    if (ql <= tl && tr <= qr) {
        return sum[v];
    }
    int mid = tl + tr >> 1;
    return query(ls[v], tl, mid, ql, qr) + query(rs[v], mid + 1, tr, ql, qr);
}
int find_first(int v, int tl, int tr, int p) {
    if (tr < p || !sum[v]) {
        return n + 1;
    }
    if (tl == tr) {
        return sum[v] > 0 ? tl : n + 1;
    }
    int mid = tl + tr >> 1;
    int ans_l = find_first(ls[v], tl, mid, p);
    if (ans_l == n + 1)
        return find_first(rs[v], mid + 1, tr, p);
    else
        return ans_l;
}
int find_last(int v, int tl, int tr, int p) {
    if (tl > p || !sum[v]) {
        return 0;
    }
    if (tl == tr) {
        return sum[v] > 0 ? tl : 0;
    }
    int mid = tl + tr >> 1;
    int ans_r = find_last(ls[v], mid + 1, tr, p);
    if (ans_r == 0)
        return find_last(ls[v], tl, mid, p);
    else
        return ans_r;
}
struct node {
    int mn, mx, l_diff, r_diff;
};
node comb(node nl, node nr) {
    node res;
    res.mn = min(nl.mn, nr.mn);
    res.mx = max(nl.mx, nr.mx);
    res.l_diff = max({nl.l_diff, nr.l_diff, nr.mx - nl.mn});
    res.r_diff = max({nl.r_diff, nr.r_diff, nl.mx - nr.mn});
    return res;
}
namespace segtree {
    node st[8 * N];
    void build(int v, int tl, int tr) {
        if (tl == tr) {
            st[v].mn = a[tl];
            st[v].mx = a[tl];
            st[v].l_diff = 0;
            st[v].r_diff = 0;
            return;
        }
        int mid = tl + tr >> 1;
        build(v * 2, tl, mid);
        build(v * 2 + 1, mid + 1, tr);
        st[v] = comb(st[v * 2], st[v * 2 + 1]);
    }
    node query(int v, int tl, int tr, int ql, int qr) {
        if (tl > tr || tl > qr || tr < ql) {
            assert(false);
        }
        if (ql <= tl && tr <= qr) {
            return st[v];
        }
        int mid = tl + tr >> 1;
        if (qr <= mid) {
            return query(v * 2, tl, mid, ql, qr);
        } else if (ql > mid) {
            return query(v * 2 + 1, mid + 1, tr, ql, qr);
        } else {
            return comb(query(v * 2, tl, mid, ql, qr), query(v * 2 + 1, mid + 1, tr, ql, qr));
        }
    }
};
vector<pair<int, int>> qs;
vector<int> roots;
void init(int N, vector<int> H) {
    n = N;
    for (int i = 1; i <= n; i++) {
        a[i] = H[i - 1];
    }
    segtree::build(1, 1, n);
    go_r[1] = 1;
    for (int i = 2; i <= n; i++) {
        go_r[i] = (a[i - 1] < a[i] ? go_r[i - 1] : i);
    }
    go_l[n] = n;
    for (int i = n - 1; i >= 1; i--) {
        go_l[i] = (a[i + 1] < a[i] ? go_l[i + 1] : i);
    }
    vector <int> stk;
    for (int i = 1; i <= n; i++) {
        while (!stk.empty() && a[stk.back()] > a[i]) stk.pop_back();
        pl[i] = (stk.empty() ? -1 : stk.back());
        stk.push_back(i);
    }
    stk.clear();
    for (int i = n; i >= 1; i--) {
        while (!stk.empty() && a[stk.back()] > a[i]) stk.pop_back();
        pr[i] = (stk.empty() ? -1 : stk.back());
        stk.push_back(i);
    }
    buildST();
    for (int i = 1; i <= n; i++) ord[i] = i;
    sort(ord + 1, ord + n + 1, cmp);
    for (int _i = 2; _i <= n; _i++) {
        int i = ord[_i];
        int D = 1.001e9;
        if (pl[i] != -1) D = min(D, qmx(pl[i] + 1, i) - a[i]);
        if (pr[i] != -1) D = min(D, qmx(i, pr[i] - 1) - a[i]);
        qs.emplace_back(D, i);
    }
    sort(qs.begin(), qs.end());
    roots.push_back(0);
    modify(roots.back(), roots.back(), 1, n, ord[1], 1);
    int sz = (int) qs.size();
    for (int i = sz - 1; i >= 0; i--) {
        int prv = (int) roots.back();
        roots.push_back(0);
        modify(roots.back(), prv, 1, n, qs[i].second, 1);
    }
    reverse(roots.begin(), roots.end());
}
int get_pos(int d) {
    int low = 0, high = (int) qs.size() - 1, res = high + 1;
    while (low <= high) {
        int mid = low + high >> 1;
        if (qs[mid].first >= d) {
            res = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }
    return res;
}
int find_first_bs(int rt, int p) {
    int low = p, high = n, res = n;
    while (low <= high) {
        int mid = low + high >> 1;
        if (query(rt, 1, n, p, mid) > 0) {
            res = mid;
            high = mid - 1;
        } else {
            low = mid + 1;
        }
    }
    return res;
}
int find_last_bs(int rt, int p) {
    int low = 1, high = p, res = 1;
    while (low <= high) {
        int mid = low + high >> 1;
        if (query(rt, 1, n, mid, p) > 0) {
            res = mid;
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }
    return res;
}
int max_towers(int L, int R, int D) {
    if (L == R) {
        return 1;
    }
    ++L; ++R;
    int p = get_pos(D);
    int ans = query(roots[p], 1, n, L, R);
    if (ans == 0) {
        int low = L, high = R, pos = R;
        while (low <= high) {
            int mid = low + high >> 1;
            if (segtree::query(1, 1, n, L, mid).l_diff >= D) {
                pos = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        if (segtree::query(1, 1, n, L, pos).l_diff >= D && segtree::query(1, 1, n, pos, R).r_diff >= D)
            return 2;
        else
            return 1;
    }
    int l = find_first_bs(roots[p], L);
    int r = find_last_bs(roots[p], R);
    if (L < l) {
        int low = L, high = l - 1, pos = l;
        while (low <= high) {
            int mid = low + high >> 1;
            if (qmx(mid, l - 1) >= a[l] + D) {
                pos = mid;
                low = mid + 1;
            } else {
                high = mid - 1;
            }
        }
        if (pos != l && segtree::query(1, 1, n, L, pos).l_diff >= D) {
            ans += 1;
        }
    }
    if (r < R) {
        int low = r + 1, high = R, pos = r;
        while (low <= high) {
            int mid = low + high >> 1;
            if (qmx(r + 1, mid) >= a[r] + D) {
                pos = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        if (pos != r && segtree::query(1, 1, n, pos, R).r_diff >= D) {
            ans += 1;
        }
    }
//    for (int i = L; i < l; i++) {
//        if (max(a[i], a[l]) <= qmx(i, l) - D) {
//            ans += 1;
//            break;
//        }
//    }
//    for (int i = R; i > r; i--) {
//        if (max(a[r], a[i]) <= qmx(r, i) - D) {
//            ans += 1;
//            break;
//        }
//    }
    return ans;
}

/*
7 3
10 20 60 40 50 30 70
1 5 10
2 2 100
0 6 17


3
1
2
*/

Compilation message

towers.cpp: In function 'void modify(int&, int, int, int, int, int)':
towers.cpp:31:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |     int mid = tl + tr >> 1;
      |               ~~~^~~~
towers.cpp: In function 'int query(int, int, int, int, int)':
towers.cpp:45:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |     int mid = tl + tr >> 1;
      |               ~~~^~~~
towers.cpp: In function 'int find_first(int, int, int, int)':
towers.cpp:55:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   55 |     int mid = tl + tr >> 1;
      |               ~~~^~~~
towers.cpp: In function 'int find_last(int, int, int, int)':
towers.cpp:69:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   69 |     int mid = tl + tr >> 1;
      |               ~~~^~~~
towers.cpp: In function 'void segtree::build(int, int, int)':
towers.cpp:97:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   97 |         int mid = tl + tr >> 1;
      |                   ~~~^~~~
towers.cpp: In function 'node segtree::query(int, int, int, int, int)':
towers.cpp:109:22: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  109 |         int mid = tl + tr >> 1;
      |                   ~~~^~~~
towers.cpp: In function 'int get_pos(int)':
towers.cpp:171:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  171 |         int mid = low + high >> 1;
      |                   ~~~~^~~~~~
towers.cpp: In function 'int find_first_bs(int, int)':
towers.cpp:184:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  184 |         int mid = low + high >> 1;
      |                   ~~~~^~~~~~
towers.cpp: In function 'int find_last_bs(int, int)':
towers.cpp:197:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  197 |         int mid = low + high >> 1;
      |                   ~~~~^~~~~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:217:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  217 |             int mid = low + high >> 1;
      |                       ~~~~^~~~~~
towers.cpp:235:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  235 |             int mid = low + high >> 1;
      |                       ~~~~^~~~~~
towers.cpp:250:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  250 |             int mid = low + high >> 1;
      |                       ~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 558 ms 22544 KB Output is correct
2 Correct 1030 ms 39312 KB Output is correct
3 Correct 1244 ms 39308 KB Output is correct
4 Correct 1192 ms 39300 KB Output is correct
5 Correct 1214 ms 39344 KB Output is correct
6 Correct 1065 ms 39352 KB Output is correct
7 Correct 1182 ms 39360 KB Output is correct
8 Correct 0 ms 372 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 944 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 2 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 976 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 928 KB Output is correct
14 Correct 1 ms 976 KB Output is correct
15 Correct 1 ms 976 KB Output is correct
16 Correct 2 ms 976 KB Output is correct
17 Correct 1 ms 976 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 1 ms 976 KB Output is correct
20 Correct 1 ms 976 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 976 KB Output is correct
23 Correct 1 ms 976 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 976 KB Output is correct
27 Correct 1 ms 976 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 2 ms 976 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 976 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 944 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 2 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 976 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 928 KB Output is correct
14 Correct 1 ms 976 KB Output is correct
15 Correct 1 ms 976 KB Output is correct
16 Correct 2 ms 976 KB Output is correct
17 Correct 1 ms 976 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 1 ms 976 KB Output is correct
20 Correct 1 ms 976 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 976 KB Output is correct
23 Correct 1 ms 976 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 976 KB Output is correct
27 Correct 1 ms 976 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 2 ms 976 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 976 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 976 KB Output is correct
36 Correct 39 ms 24248 KB Output is correct
37 Correct 71 ms 39000 KB Output is correct
38 Correct 58 ms 38928 KB Output is correct
39 Correct 60 ms 38980 KB Output is correct
40 Correct 60 ms 38972 KB Output is correct
41 Correct 67 ms 38956 KB Output is correct
42 Correct 59 ms 38916 KB Output is correct
43 Correct 42 ms 39404 KB Output is correct
44 Correct 41 ms 39324 KB Output is correct
45 Correct 44 ms 39216 KB Output is correct
46 Correct 44 ms 39224 KB Output is correct
47 Correct 69 ms 38952 KB Output is correct
48 Correct 58 ms 38924 KB Output is correct
49 Correct 59 ms 39020 KB Output is correct
50 Correct 41 ms 39412 KB Output is correct
51 Correct 51 ms 39304 KB Output is correct
52 Correct 62 ms 38972 KB Output is correct
53 Correct 59 ms 38972 KB Output is correct
54 Correct 57 ms 38960 KB Output is correct
55 Correct 42 ms 39360 KB Output is correct
56 Correct 47 ms 39196 KB Output is correct
57 Correct 57 ms 37768 KB Output is correct
58 Correct 64 ms 39108 KB Output is correct
59 Correct 61 ms 38928 KB Output is correct
60 Correct 59 ms 38936 KB Output is correct
61 Correct 61 ms 38928 KB Output is correct
62 Correct 59 ms 38932 KB Output is correct
63 Correct 66 ms 38952 KB Output is correct
64 Correct 45 ms 39416 KB Output is correct
65 Correct 40 ms 39348 KB Output is correct
66 Correct 46 ms 39180 KB Output is correct
67 Correct 43 ms 39324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1176 ms 38760 KB Output is correct
2 Correct 1607 ms 38996 KB Output is correct
3 Correct 1467 ms 38972 KB Output is correct
4 Correct 1409 ms 39016 KB Output is correct
5 Correct 1633 ms 38984 KB Output is correct
6 Correct 1498 ms 38972 KB Output is correct
7 Correct 1453 ms 38948 KB Output is correct
8 Correct 989 ms 39340 KB Output is correct
9 Correct 1201 ms 39304 KB Output is correct
10 Correct 1362 ms 39232 KB Output is correct
11 Correct 1524 ms 39232 KB Output is correct
12 Correct 1148 ms 39344 KB Output is correct
13 Correct 1058 ms 39376 KB Output is correct
14 Correct 0 ms 336 KB Output is correct
15 Correct 1 ms 976 KB Output is correct
16 Correct 1 ms 976 KB Output is correct
17 Correct 64 ms 39064 KB Output is correct
18 Correct 58 ms 39000 KB Output is correct
19 Correct 59 ms 39020 KB Output is correct
20 Correct 40 ms 39344 KB Output is correct
21 Correct 47 ms 39352 KB Output is correct
22 Correct 59 ms 39016 KB Output is correct
23 Correct 59 ms 38948 KB Output is correct
24 Correct 60 ms 38964 KB Output is correct
25 Correct 39 ms 39316 KB Output is correct
26 Correct 47 ms 39104 KB Output is correct
27 Correct 1 ms 976 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 1 ms 976 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 976 KB Output is correct
36 Correct 1 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 9036 KB Output is correct
2 Correct 980 ms 38972 KB Output is correct
3 Correct 1126 ms 38940 KB Output is correct
4 Correct 1238 ms 38948 KB Output is correct
5 Correct 1071 ms 38976 KB Output is correct
6 Correct 1211 ms 38932 KB Output is correct
7 Correct 1008 ms 38960 KB Output is correct
8 Correct 963 ms 39320 KB Output is correct
9 Correct 1008 ms 39324 KB Output is correct
10 Correct 900 ms 39228 KB Output is correct
11 Correct 876 ms 39280 KB Output is correct
12 Correct 61 ms 38992 KB Output is correct
13 Correct 58 ms 38952 KB Output is correct
14 Correct 59 ms 38920 KB Output is correct
15 Correct 40 ms 39352 KB Output is correct
16 Correct 47 ms 39136 KB Output is correct
17 Correct 57 ms 37780 KB Output is correct
18 Correct 60 ms 38920 KB Output is correct
19 Correct 58 ms 38932 KB Output is correct
20 Correct 59 ms 38980 KB Output is correct
21 Correct 58 ms 38920 KB Output is correct
22 Correct 60 ms 39088 KB Output is correct
23 Correct 57 ms 38928 KB Output is correct
24 Correct 42 ms 39360 KB Output is correct
25 Correct 40 ms 39320 KB Output is correct
26 Correct 45 ms 39212 KB Output is correct
27 Correct 43 ms 39316 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 1 ms 976 KB Output is correct
31 Correct 1 ms 932 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 592 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 948 KB Output is correct
36 Correct 1 ms 976 KB Output is correct
37 Correct 1 ms 976 KB Output is correct
38 Correct 1 ms 976 KB Output is correct
39 Correct 1 ms 976 KB Output is correct
40 Correct 1 ms 976 KB Output is correct
41 Correct 1 ms 976 KB Output is correct
42 Correct 1 ms 976 KB Output is correct
43 Correct 1 ms 976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 464 KB Output is correct
2 Correct 1 ms 976 KB Output is correct
3 Correct 1 ms 944 KB Output is correct
4 Correct 1 ms 976 KB Output is correct
5 Correct 1 ms 976 KB Output is correct
6 Correct 2 ms 976 KB Output is correct
7 Correct 1 ms 976 KB Output is correct
8 Correct 1 ms 976 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 976 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 928 KB Output is correct
14 Correct 1 ms 976 KB Output is correct
15 Correct 1 ms 976 KB Output is correct
16 Correct 2 ms 976 KB Output is correct
17 Correct 1 ms 976 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 1 ms 976 KB Output is correct
20 Correct 1 ms 976 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 976 KB Output is correct
23 Correct 1 ms 976 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 592 KB Output is correct
26 Correct 1 ms 976 KB Output is correct
27 Correct 1 ms 976 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 2 ms 976 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 976 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 976 KB Output is correct
36 Correct 39 ms 24248 KB Output is correct
37 Correct 71 ms 39000 KB Output is correct
38 Correct 58 ms 38928 KB Output is correct
39 Correct 60 ms 38980 KB Output is correct
40 Correct 60 ms 38972 KB Output is correct
41 Correct 67 ms 38956 KB Output is correct
42 Correct 59 ms 38916 KB Output is correct
43 Correct 42 ms 39404 KB Output is correct
44 Correct 41 ms 39324 KB Output is correct
45 Correct 44 ms 39216 KB Output is correct
46 Correct 44 ms 39224 KB Output is correct
47 Correct 69 ms 38952 KB Output is correct
48 Correct 58 ms 38924 KB Output is correct
49 Correct 59 ms 39020 KB Output is correct
50 Correct 41 ms 39412 KB Output is correct
51 Correct 51 ms 39304 KB Output is correct
52 Correct 62 ms 38972 KB Output is correct
53 Correct 59 ms 38972 KB Output is correct
54 Correct 57 ms 38960 KB Output is correct
55 Correct 42 ms 39360 KB Output is correct
56 Correct 47 ms 39196 KB Output is correct
57 Correct 57 ms 37768 KB Output is correct
58 Correct 64 ms 39108 KB Output is correct
59 Correct 61 ms 38928 KB Output is correct
60 Correct 59 ms 38936 KB Output is correct
61 Correct 61 ms 38928 KB Output is correct
62 Correct 59 ms 38932 KB Output is correct
63 Correct 66 ms 38952 KB Output is correct
64 Correct 45 ms 39416 KB Output is correct
65 Correct 40 ms 39348 KB Output is correct
66 Correct 46 ms 39180 KB Output is correct
67 Correct 43 ms 39324 KB Output is correct
68 Correct 1176 ms 38760 KB Output is correct
69 Correct 1607 ms 38996 KB Output is correct
70 Correct 1467 ms 38972 KB Output is correct
71 Correct 1409 ms 39016 KB Output is correct
72 Correct 1633 ms 38984 KB Output is correct
73 Correct 1498 ms 38972 KB Output is correct
74 Correct 1453 ms 38948 KB Output is correct
75 Correct 989 ms 39340 KB Output is correct
76 Correct 1201 ms 39304 KB Output is correct
77 Correct 1362 ms 39232 KB Output is correct
78 Correct 1524 ms 39232 KB Output is correct
79 Correct 1148 ms 39344 KB Output is correct
80 Correct 1058 ms 39376 KB Output is correct
81 Correct 0 ms 336 KB Output is correct
82 Correct 1 ms 976 KB Output is correct
83 Correct 1 ms 976 KB Output is correct
84 Correct 64 ms 39064 KB Output is correct
85 Correct 58 ms 39000 KB Output is correct
86 Correct 59 ms 39020 KB Output is correct
87 Correct 40 ms 39344 KB Output is correct
88 Correct 47 ms 39352 KB Output is correct
89 Correct 59 ms 39016 KB Output is correct
90 Correct 59 ms 38948 KB Output is correct
91 Correct 60 ms 38964 KB Output is correct
92 Correct 39 ms 39316 KB Output is correct
93 Correct 47 ms 39104 KB Output is correct
94 Correct 1 ms 976 KB Output is correct
95 Correct 1 ms 976 KB Output is correct
96 Correct 1 ms 976 KB Output is correct
97 Correct 1 ms 976 KB Output is correct
98 Correct 1 ms 976 KB Output is correct
99 Correct 1 ms 976 KB Output is correct
100 Correct 1 ms 860 KB Output is correct
101 Correct 1 ms 976 KB Output is correct
102 Correct 1 ms 976 KB Output is correct
103 Correct 1 ms 976 KB Output is correct
104 Correct 1140 ms 35044 KB Output is correct
105 Correct 1525 ms 38972 KB Output is correct
106 Correct 1569 ms 38972 KB Output is correct
107 Correct 1556 ms 38960 KB Output is correct
108 Correct 1279 ms 38972 KB Output is correct
109 Correct 1513 ms 38928 KB Output is correct
110 Correct 1495 ms 38960 KB Output is correct
111 Correct 1014 ms 39360 KB Output is correct
112 Correct 1066 ms 39364 KB Output is correct
113 Correct 1251 ms 39160 KB Output is correct
114 Correct 1374 ms 39284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 558 ms 22544 KB Output is correct
2 Correct 1030 ms 39312 KB Output is correct
3 Correct 1244 ms 39308 KB Output is correct
4 Correct 1192 ms 39300 KB Output is correct
5 Correct 1214 ms 39344 KB Output is correct
6 Correct 1065 ms 39352 KB Output is correct
7 Correct 1182 ms 39360 KB Output is correct
8 Correct 0 ms 372 KB Output is correct
9 Correct 1 ms 976 KB Output is correct
10 Correct 1 ms 976 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 976 KB Output is correct
13 Correct 1 ms 944 KB Output is correct
14 Correct 1 ms 976 KB Output is correct
15 Correct 1 ms 976 KB Output is correct
16 Correct 2 ms 976 KB Output is correct
17 Correct 1 ms 976 KB Output is correct
18 Correct 1 ms 976 KB Output is correct
19 Correct 1 ms 976 KB Output is correct
20 Correct 1 ms 976 KB Output is correct
21 Correct 1 ms 976 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 928 KB Output is correct
24 Correct 1 ms 976 KB Output is correct
25 Correct 1 ms 976 KB Output is correct
26 Correct 2 ms 976 KB Output is correct
27 Correct 1 ms 976 KB Output is correct
28 Correct 1 ms 976 KB Output is correct
29 Correct 1 ms 976 KB Output is correct
30 Correct 1 ms 976 KB Output is correct
31 Correct 1 ms 976 KB Output is correct
32 Correct 1 ms 976 KB Output is correct
33 Correct 1 ms 976 KB Output is correct
34 Correct 1 ms 976 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 1 ms 976 KB Output is correct
37 Correct 1 ms 976 KB Output is correct
38 Correct 1 ms 976 KB Output is correct
39 Correct 1 ms 976 KB Output is correct
40 Correct 2 ms 976 KB Output is correct
41 Correct 1 ms 976 KB Output is correct
42 Correct 1 ms 976 KB Output is correct
43 Correct 1 ms 976 KB Output is correct
44 Correct 1 ms 976 KB Output is correct
45 Correct 1 ms 976 KB Output is correct
46 Correct 39 ms 24248 KB Output is correct
47 Correct 71 ms 39000 KB Output is correct
48 Correct 58 ms 38928 KB Output is correct
49 Correct 60 ms 38980 KB Output is correct
50 Correct 60 ms 38972 KB Output is correct
51 Correct 67 ms 38956 KB Output is correct
52 Correct 59 ms 38916 KB Output is correct
53 Correct 42 ms 39404 KB Output is correct
54 Correct 41 ms 39324 KB Output is correct
55 Correct 44 ms 39216 KB Output is correct
56 Correct 44 ms 39224 KB Output is correct
57 Correct 69 ms 38952 KB Output is correct
58 Correct 58 ms 38924 KB Output is correct
59 Correct 59 ms 39020 KB Output is correct
60 Correct 41 ms 39412 KB Output is correct
61 Correct 51 ms 39304 KB Output is correct
62 Correct 62 ms 38972 KB Output is correct
63 Correct 59 ms 38972 KB Output is correct
64 Correct 57 ms 38960 KB Output is correct
65 Correct 42 ms 39360 KB Output is correct
66 Correct 47 ms 39196 KB Output is correct
67 Correct 57 ms 37768 KB Output is correct
68 Correct 64 ms 39108 KB Output is correct
69 Correct 61 ms 38928 KB Output is correct
70 Correct 59 ms 38936 KB Output is correct
71 Correct 61 ms 38928 KB Output is correct
72 Correct 59 ms 38932 KB Output is correct
73 Correct 66 ms 38952 KB Output is correct
74 Correct 45 ms 39416 KB Output is correct
75 Correct 40 ms 39348 KB Output is correct
76 Correct 46 ms 39180 KB Output is correct
77 Correct 43 ms 39324 KB Output is correct
78 Correct 1176 ms 38760 KB Output is correct
79 Correct 1607 ms 38996 KB Output is correct
80 Correct 1467 ms 38972 KB Output is correct
81 Correct 1409 ms 39016 KB Output is correct
82 Correct 1633 ms 38984 KB Output is correct
83 Correct 1498 ms 38972 KB Output is correct
84 Correct 1453 ms 38948 KB Output is correct
85 Correct 989 ms 39340 KB Output is correct
86 Correct 1201 ms 39304 KB Output is correct
87 Correct 1362 ms 39232 KB Output is correct
88 Correct 1524 ms 39232 KB Output is correct
89 Correct 1148 ms 39344 KB Output is correct
90 Correct 1058 ms 39376 KB Output is correct
91 Correct 0 ms 336 KB Output is correct
92 Correct 1 ms 976 KB Output is correct
93 Correct 1 ms 976 KB Output is correct
94 Correct 64 ms 39064 KB Output is correct
95 Correct 58 ms 39000 KB Output is correct
96 Correct 59 ms 39020 KB Output is correct
97 Correct 40 ms 39344 KB Output is correct
98 Correct 47 ms 39352 KB Output is correct
99 Correct 59 ms 39016 KB Output is correct
100 Correct 59 ms 38948 KB Output is correct
101 Correct 60 ms 38964 KB Output is correct
102 Correct 39 ms 39316 KB Output is correct
103 Correct 47 ms 39104 KB Output is correct
104 Correct 1 ms 976 KB Output is correct
105 Correct 1 ms 976 KB Output is correct
106 Correct 1 ms 976 KB Output is correct
107 Correct 1 ms 976 KB Output is correct
108 Correct 1 ms 976 KB Output is correct
109 Correct 1 ms 976 KB Output is correct
110 Correct 1 ms 860 KB Output is correct
111 Correct 1 ms 976 KB Output is correct
112 Correct 1 ms 976 KB Output is correct
113 Correct 1 ms 976 KB Output is correct
114 Correct 268 ms 9036 KB Output is correct
115 Correct 980 ms 38972 KB Output is correct
116 Correct 1126 ms 38940 KB Output is correct
117 Correct 1238 ms 38948 KB Output is correct
118 Correct 1071 ms 38976 KB Output is correct
119 Correct 1211 ms 38932 KB Output is correct
120 Correct 1008 ms 38960 KB Output is correct
121 Correct 963 ms 39320 KB Output is correct
122 Correct 1008 ms 39324 KB Output is correct
123 Correct 900 ms 39228 KB Output is correct
124 Correct 876 ms 39280 KB Output is correct
125 Correct 61 ms 38992 KB Output is correct
126 Correct 58 ms 38952 KB Output is correct
127 Correct 59 ms 38920 KB Output is correct
128 Correct 40 ms 39352 KB Output is correct
129 Correct 47 ms 39136 KB Output is correct
130 Correct 57 ms 37780 KB Output is correct
131 Correct 60 ms 38920 KB Output is correct
132 Correct 58 ms 38932 KB Output is correct
133 Correct 59 ms 38980 KB Output is correct
134 Correct 58 ms 38920 KB Output is correct
135 Correct 60 ms 39088 KB Output is correct
136 Correct 57 ms 38928 KB Output is correct
137 Correct 42 ms 39360 KB Output is correct
138 Correct 40 ms 39320 KB Output is correct
139 Correct 45 ms 39212 KB Output is correct
140 Correct 43 ms 39316 KB Output is correct
141 Correct 1 ms 976 KB Output is correct
142 Correct 1 ms 976 KB Output is correct
143 Correct 1 ms 976 KB Output is correct
144 Correct 1 ms 932 KB Output is correct
145 Correct 1 ms 976 KB Output is correct
146 Correct 1 ms 592 KB Output is correct
147 Correct 1 ms 976 KB Output is correct
148 Correct 1 ms 948 KB Output is correct
149 Correct 1 ms 976 KB Output is correct
150 Correct 1 ms 976 KB Output is correct
151 Correct 1 ms 976 KB Output is correct
152 Correct 1 ms 976 KB Output is correct
153 Correct 1 ms 976 KB Output is correct
154 Correct 1 ms 976 KB Output is correct
155 Correct 1 ms 976 KB Output is correct
156 Correct 1 ms 976 KB Output is correct
157 Correct 1140 ms 35044 KB Output is correct
158 Correct 1525 ms 38972 KB Output is correct
159 Correct 1569 ms 38972 KB Output is correct
160 Correct 1556 ms 38960 KB Output is correct
161 Correct 1279 ms 38972 KB Output is correct
162 Correct 1513 ms 38928 KB Output is correct
163 Correct 1495 ms 38960 KB Output is correct
164 Correct 1014 ms 39360 KB Output is correct
165 Correct 1066 ms 39364 KB Output is correct
166 Correct 1251 ms 39160 KB Output is correct
167 Correct 1374 ms 39284 KB Output is correct
168 Correct 0 ms 336 KB Output is correct
169 Correct 835 ms 13796 KB Output is correct
170 Correct 1565 ms 39008 KB Output is correct
171 Correct 1556 ms 38932 KB Output is correct
172 Correct 1734 ms 38940 KB Output is correct
173 Correct 1612 ms 38928 KB Output is correct
174 Correct 1700 ms 38920 KB Output is correct
175 Correct 1735 ms 38908 KB Output is correct
176 Correct 1132 ms 39328 KB Output is correct
177 Correct 1125 ms 39344 KB Output is correct
178 Correct 1332 ms 39320 KB Output is correct
179 Correct 1141 ms 39088 KB Output is correct