답안 #687315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
687315 2023-01-26T09:44:42 Z 79brue 송신탑 (IOI22_towers) C++17
100 / 100
2496 ms 454660 KB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
int arr[100002];

/** 세그먼트 트리 */
struct segTree{
    int minV[400002], maxV[400002];

    void init(int i, int l, int r, int *A){
        if(l==r){
            minV[i] = maxV[i] = A[l];
            return;
        }
        int m = (l+r)>>1;
        init(i*2, l, m, A);
        init(i*2+1, m+1, r, A);
        minV[i] = min(minV[i*2], minV[i*2+1]);
        maxV[i] = max(maxV[i*2], maxV[i*2+1]);
    }

    int queryMin(int i, int l, int r, int s, int e){
        if(r<s || e<l) return INT_MAX;
        if(s<=l && r<=e) return minV[i];
        int m = (l+r)>>1;
        return min(queryMin(i*2, l, m, s, e), queryMin(i*2+1, m+1, r, s, e));
    }

    int queryMax(int i, int l, int r, int s, int e){
        if(r<s || e<l) return INT_MIN;
        if(s<=l && r<=e) return maxV[i];
        int m = (l+r)>>1;
        return max(queryMax(i*2, l, m, s, e), queryMax(i*2+1, m+1, r, s, e));
    }
} segtree;

void calculateIntervals();

void init(int N, vector<int> H){
    n = N;
    for(int i=0; i<n; i++) arr[i] = H[i];

    segtree.init(1, 0, n-1, arr);
    calculateIntervals();
}

/** PST 구조체
 *  1. 구간 합 쿼리 처리 기능
 *  2. 어떤 pair (x, y)가 들어올 때, 지금까지 들어온 pair의 max 처리 기능
 */
struct PST{
    struct Node{
        Node *lc, *rc;
        int sum;
        pair<int, int> lPair, rPair;

        Node(Node* node){
            lc = node->lc, rc = node->rc;
            sum = node->sum;
            lPair = node->lPair, rPair = node->rPair;
        }

        Node(int l, int r){
            lc = rc = nullptr;
            sum = 0;
            lPair = rPair = make_pair(-1, -1);

            if(l==r) return;
            int m = (l+r)>>1;
            lc = new Node(l, m);
            rc = new Node(m+1, r);
        }

        Node* update(int l, int r, int x, int v){
            if(l==r){
                Node *node = new Node(this);
                node->sum += v;
                return node;
            }
            int m = (l+r)>>1;
            Node *node = new Node(this);
            if(x<=m){
                node->lc = lc->update(l, m, x, v);
                node->sum += v;
                return node;
            }
            else{
                node->rc = rc->update(m+1, r, x, v);
                node->sum += v;
                return node;
            }
        }

        Node* updateL(int l, int r, int s, int e, pair<int, int> p){
            if(r<s || e<l) return this;
            if(s<=l && r<=e){
                Node *node = new Node(this);
                node->lPair = p;
                return node;
            }
            int m = (l+r)>>1;
            Node *node = new Node(this);
            node->lc = lc->updateL(l, m, s, e, p);
            node->rc = rc->updateL(m+1, r, s, e, p);
            return node;
        }

        Node* updateR(int l, int r, int s, int e, pair<int, int> p){
            if(r<s || e<l) return this;
            if(s<=l && r<=e){
                Node *node = new Node(this);
                node->rPair = p;
                return node;
            }
            int m = (l+r)>>1;
            Node *node = new Node(this);
            node->lc = lc->updateR(l, m, s, e, p);
            node->rc = rc->updateR(m+1, r, s, e, p);
            return node;
        }

        int query(int l, int r, int s, int e){
            if(r<s || e<l) return 0;
            if(s<=l && r<=e) return sum;
            int m = (l+r)>>1;
            return lc->query(l, m, s, e) + rc->query(m+1, r, s, e);
        }

        pair<int, int> queryL(int l, int r, int x){
            if(l==r) return lPair;
            int m = (l+r)>>1;
            if(x<=m) return max(lPair, lc->queryL(l, m, x));
            else return max(lPair, rc->queryL(m+1, r, x));
        }

        pair<int, int> queryR(int l, int r, int x){
            if(l==r) return rPair;
            int m = (l+r)>>1;
            if(x<=m) return max(rPair, lc->queryR(l, m, x));
            else return max(rPair, rc->queryR(m+1, r, x));
        }
    } *root;
    int n, curD;
    Node *history[200002];

    PST(){}

    void init(int N){
        n = N;
        root = new Node(0, n-1);
        curD = 0;
        memset(history, 0, sizeof(history));
    }

    void nextD(){
        history[curD++] = root;
    }

    void update(int x, int v){
        root = root->update(0, n-1, x, v);
    }

    void updateL(int l, int r, int idx){
        root = root->updateL(0, n-1, l, r, make_pair(curD, idx));
    }

    void updateR(int l, int r, int idx){
        root = root->updateR(0, n-1, l, r, make_pair(curD, idx));
    }

    vector<int> query(int l, int r, int d){
        /// 정수 3개의 배열을 리턴
        vector<int> ret (3);
        ret[0] = history[d]->query(0, n-1, l, r);
        ret[1] = history[d]->queryL(0, n-1, l).second;
        ret[2] = history[d]->queryR(0, n-1, r).second;

        return ret;
    }

    int queryL(int x, int d){
        return history[d]->queryL(0, n-1, x).second;
    }

    int queryR(int x, int d){
        return history[d]->queryR(0, n-1, x).second;
    }
} tree;

struct Interval{
    int s, e, diff, idx;
    Interval(int s, int e, int diff, int idx): s(s), e(e), diff(diff), idx(idx){}
};

struct xOrder {
    bool operator() (const Interval &l, const Interval &r)const{
        return l.s < r.s;
    }
};

struct diffOrder {
    bool operator() (const Interval &l, const Interval &r)const{
        if(abs(l.diff) != abs(r.diff)) return abs(l.diff) < abs(r.diff);
        return l.s < r.s;
    }
};

set<Interval, xOrder> xSet;
set<Interval, diffOrder> diffSet;

int sgn(int x){
    return x > 0 ? 1 : x == 0 ? 0 : -1;
}

vector<int> diffScale;
vector<Interval> intervals;
int leftInt[200002], rightInt[200002];

void makeInitialIntervals(){ /// 초기의 구간들을 계산한다
    tree.init(n);

    int prv = 0;
    while(prv < n-1){
        int j = prv;
        while(j+1<n && sgn(arr[j] - arr[prv]) * sgn(arr[j+1] - arr[j]) >= 0) j++;
        if(arr[j] == arr[prv]) break;

        /// 현재 찾은 구간을 셋에 집어넣는다
        int idx = (int)intervals.size();
        Interval tmp = Interval(prv, j, arr[j] - arr[prv], idx);
        intervals.push_back(tmp);
        xSet.insert(tmp);
        diffSet.insert(tmp);

        /// 현재 찾은 구간을 트리에 업데이트한다
        tree.update(prv, 1);
        tree.updateL(prv+1, j, idx);
        tree.updateR(prv, j-1, idx);

        prv = j;
    }
    diffScale.push_back(0);
    leftInt[tree.curD] = (xSet.empty() ? -1 : xSet.begin()->idx);
    rightInt[tree.curD] = (xSet.empty() ? -1 : xSet.rbegin()->idx);
    tree.nextD();
}

void calculateChanges(){ /// D가 커짐에 따라 생기는 변화들을 구한다
    while((int)diffSet.size()){
        int D = abs(diffSet.begin()->diff); /// 현재의 차이값
        while(abs((int)diffSet.begin()->diff) == D){ /// 해당하는 차이의 모든 구간을 처리한다.
            /// 구간을 뽑는다
            Interval p = *diffSet.begin();
            diffSet.erase(diffSet.begin());

            /// Case 1. 직전에 구간이 존재하지 않음
            if(xSet.begin()->s == p.s){ /// 이 구간은 그냥 삭제한다.
                xSet.erase(xSet.begin());
                tree.update(p.s, -1);
                tree.updateL(0, p.e, -1);
            }
            /// Case 2. 직후에 구간이 존재하지 않음
            else if(xSet.rbegin()->s == p.s){ /// 이 구간 역시 그냥 삭제한다.
                xSet.erase(prev(xSet.end()));
                tree.update(p.s, -1);
                tree.updateR(p.s, n-1, -1);
            }
            /// Case 3. 양쪽 모두 잘 존재함
            else{ /// 새로운 구간을 만들어 준다.
                auto it = xSet.find(p);
                int ns = prev(it)->s, ne = next(it)->e;
                int idx = (int)intervals.size();
                Interval np = Interval(ns, ne, arr[ne] - arr[ns], idx);
                intervals.push_back(np);

                /// 셋에 반영한다.
                diffSet.erase(*prev(it)), diffSet.erase(*next(it));
                xSet.erase(prev(it)), xSet.erase(next(it));
                xSet.erase(it);
                xSet.insert(np), diffSet.insert(np);

                /// 트리에 반영한다
                tree.update(p.s, -1);
                tree.update(p.e, -1);
                tree.updateL(np.s+1, np.e, idx);
                tree.updateR(np.s, np.e-1, idx);
            }
        }

        diffScale.push_back(D+1);
        leftInt[tree.curD] = (xSet.empty() ? -1 : xSet.begin()->idx);
        rightInt[tree.curD] = (xSet.empty() ? -1 : xSet.rbegin()->idx);
        tree.nextD();
    }
    leftInt[tree.curD] = rightInt[tree.curD] = -1;
}

void calculateIntervals(){
    makeInitialIntervals();
    calculateChanges();
}

int max_towers(int L, int R, int D){
    int Rd = D;
    D = upper_bound(diffScale.begin(), diffScale.end(), D) - diffScale.begin() - 1;
    if(leftInt[D] == -1) return 1; /// 현 시기에 구간이 하나도 없는 경우

    vector<int> response = tree.query(L, R, D);
    int sum = response[0], ql = response[1], qr = response[2];

    /// 구간 시작점이 하나라도 있는 경우
    if(sum){
        /// 1. 완전히 속하는 구간의 개수를 센다.
        /// 왼쪽 끝 부분은 예외가 생기지 않는다.
        /// 오른쪽 끝 부분은 맨 오른쪽 점이 어느 구간에 포함되지 않았을 때를 제외하고는 1을 제외해야 한다.
        if(qr != -1) sum--; /// 시작점이

        /// 2. 왼쪽 끝을 본다.
        /// 위에서 본 구간 중 맨 왼쪽 구간을 찾는다.
        int lint = (ql == -1) ? leftInt[D] : tree.queryL(intervals[ql].e+1, D);
        assert(lint != -1);
        int lDir = sgn(intervals[lint].diff);
        bool lMore = abs(segtree.queryMin(1, 0, n-1, L, intervals[lint].s) - arr[intervals[lint].s]) >= Rd;

        /// 3. 오른쪽 끝을 본다
        /// 위에서 본 구간 중 맨 오른쪽 구간을 찾는다.
        int rint = (qr == -1) ? rightInt[D] : tree.queryR(intervals[qr].s-1, D);
        assert(rint != -1);
        int rDir = sgn(intervals[rint].diff);
        bool rMore = abs(segtree.queryMin(1, 0, n-1, intervals[rint].e, R) - arr[intervals[rint].e]) >= Rd;

        /// 4. 답을 계산한다
        int base = (sum - (sum >= 2 && lDir == -1)) / 2;
        if(sum == 0){
            if(lDir == -1 && lMore && rDir == 1 && rMore) return 2;
            else return 1;
        }
        if(lDir == -1 && lMore) base++;
        if(rDir == 1 && rMore) base++;
        return base+1;
    }

    /// 구간 시작점이 하나도 없는 경우
    return 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 469 ms 9208 KB Output is correct
2 Correct 973 ms 14408 KB Output is correct
3 Correct 1084 ms 14400 KB Output is correct
4 Correct 966 ms 14380 KB Output is correct
5 Correct 1066 ms 14396 KB Output is correct
6 Correct 1092 ms 14524 KB Output is correct
7 Correct 1008 ms 14408 KB Output is correct
8 Correct 1 ms 1872 KB Output is correct
9 Correct 1 ms 2128 KB Output is correct
10 Correct 2 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2640 KB Output is correct
2 Correct 10 ms 6224 KB Output is correct
3 Correct 7 ms 6224 KB Output is correct
4 Correct 10 ms 8144 KB Output is correct
5 Correct 13 ms 8144 KB Output is correct
6 Correct 9 ms 8144 KB Output is correct
7 Correct 9 ms 8144 KB Output is correct
8 Correct 1 ms 2128 KB Output is correct
9 Correct 1 ms 2128 KB Output is correct
10 Correct 1 ms 2128 KB Output is correct
11 Correct 1 ms 2128 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
13 Correct 1 ms 2128 KB Output is correct
14 Correct 2 ms 2128 KB Output is correct
15 Correct 6 ms 6352 KB Output is correct
16 Correct 10 ms 8144 KB Output is correct
17 Correct 9 ms 8144 KB Output is correct
18 Correct 2 ms 2128 KB Output is correct
19 Correct 2 ms 2128 KB Output is correct
20 Correct 7 ms 6224 KB Output is correct
21 Correct 10 ms 8240 KB Output is correct
22 Correct 11 ms 8144 KB Output is correct
23 Correct 2 ms 2128 KB Output is correct
24 Correct 2 ms 2176 KB Output is correct
25 Correct 4 ms 3664 KB Output is correct
26 Correct 9 ms 6304 KB Output is correct
27 Correct 7 ms 6152 KB Output is correct
28 Correct 10 ms 8144 KB Output is correct
29 Correct 11 ms 8192 KB Output is correct
30 Correct 10 ms 8236 KB Output is correct
31 Correct 9 ms 8144 KB Output is correct
32 Correct 2 ms 2128 KB Output is correct
33 Correct 2 ms 2128 KB Output is correct
34 Correct 2 ms 2128 KB Output is correct
35 Correct 1 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2640 KB Output is correct
2 Correct 10 ms 6224 KB Output is correct
3 Correct 7 ms 6224 KB Output is correct
4 Correct 10 ms 8144 KB Output is correct
5 Correct 13 ms 8144 KB Output is correct
6 Correct 9 ms 8144 KB Output is correct
7 Correct 9 ms 8144 KB Output is correct
8 Correct 1 ms 2128 KB Output is correct
9 Correct 1 ms 2128 KB Output is correct
10 Correct 1 ms 2128 KB Output is correct
11 Correct 1 ms 2128 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
13 Correct 1 ms 2128 KB Output is correct
14 Correct 2 ms 2128 KB Output is correct
15 Correct 6 ms 6352 KB Output is correct
16 Correct 10 ms 8144 KB Output is correct
17 Correct 9 ms 8144 KB Output is correct
18 Correct 2 ms 2128 KB Output is correct
19 Correct 2 ms 2128 KB Output is correct
20 Correct 7 ms 6224 KB Output is correct
21 Correct 10 ms 8240 KB Output is correct
22 Correct 11 ms 8144 KB Output is correct
23 Correct 2 ms 2128 KB Output is correct
24 Correct 2 ms 2176 KB Output is correct
25 Correct 4 ms 3664 KB Output is correct
26 Correct 9 ms 6304 KB Output is correct
27 Correct 7 ms 6152 KB Output is correct
28 Correct 10 ms 8144 KB Output is correct
29 Correct 11 ms 8192 KB Output is correct
30 Correct 10 ms 8236 KB Output is correct
31 Correct 9 ms 8144 KB Output is correct
32 Correct 2 ms 2128 KB Output is correct
33 Correct 2 ms 2128 KB Output is correct
34 Correct 2 ms 2128 KB Output is correct
35 Correct 1 ms 2128 KB Output is correct
36 Correct 336 ms 196192 KB Output is correct
37 Correct 542 ms 314836 KB Output is correct
38 Correct 555 ms 313292 KB Output is correct
39 Correct 823 ms 454596 KB Output is correct
40 Correct 849 ms 454400 KB Output is correct
41 Correct 832 ms 454660 KB Output is correct
42 Correct 899 ms 454572 KB Output is correct
43 Correct 20 ms 14384 KB Output is correct
44 Correct 21 ms 14500 KB Output is correct
45 Correct 20 ms 14540 KB Output is correct
46 Correct 20 ms 14520 KB Output is correct
47 Correct 613 ms 313596 KB Output is correct
48 Correct 881 ms 454444 KB Output is correct
49 Correct 850 ms 454464 KB Output is correct
50 Correct 29 ms 14400 KB Output is correct
51 Correct 21 ms 14536 KB Output is correct
52 Correct 558 ms 313600 KB Output is correct
53 Correct 824 ms 454360 KB Output is correct
54 Correct 868 ms 454436 KB Output is correct
55 Correct 21 ms 14416 KB Output is correct
56 Correct 20 ms 14428 KB Output is correct
57 Correct 544 ms 303248 KB Output is correct
58 Correct 556 ms 314212 KB Output is correct
59 Correct 542 ms 314924 KB Output is correct
60 Correct 904 ms 454492 KB Output is correct
61 Correct 877 ms 454304 KB Output is correct
62 Correct 884 ms 454440 KB Output is correct
63 Correct 964 ms 454572 KB Output is correct
64 Correct 31 ms 14388 KB Output is correct
65 Correct 28 ms 14392 KB Output is correct
66 Correct 21 ms 14552 KB Output is correct
67 Correct 25 ms 14436 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1689 ms 310848 KB Output is correct
2 Correct 1690 ms 314020 KB Output is correct
3 Correct 1714 ms 313944 KB Output is correct
4 Correct 1888 ms 454424 KB Output is correct
5 Correct 2037 ms 454412 KB Output is correct
6 Correct 2003 ms 454496 KB Output is correct
7 Correct 1842 ms 454444 KB Output is correct
8 Correct 912 ms 14400 KB Output is correct
9 Correct 928 ms 14408 KB Output is correct
10 Correct 1083 ms 14520 KB Output is correct
11 Correct 1025 ms 14516 KB Output is correct
12 Correct 971 ms 14416 KB Output is correct
13 Correct 953 ms 14516 KB Output is correct
14 Correct 2 ms 1872 KB Output is correct
15 Correct 1 ms 2128 KB Output is correct
16 Correct 1 ms 2128 KB Output is correct
17 Correct 564 ms 313500 KB Output is correct
18 Correct 836 ms 454636 KB Output is correct
19 Correct 916 ms 454540 KB Output is correct
20 Correct 26 ms 14408 KB Output is correct
21 Correct 25 ms 14536 KB Output is correct
22 Correct 571 ms 313708 KB Output is correct
23 Correct 938 ms 454436 KB Output is correct
24 Correct 860 ms 454340 KB Output is correct
25 Correct 27 ms 14380 KB Output is correct
26 Correct 27 ms 14536 KB Output is correct
27 Correct 8 ms 6352 KB Output is correct
28 Correct 10 ms 8200 KB Output is correct
29 Correct 10 ms 8144 KB Output is correct
30 Correct 1 ms 2128 KB Output is correct
31 Correct 2 ms 2128 KB Output is correct
32 Correct 8 ms 6224 KB Output is correct
33 Correct 14 ms 8164 KB Output is correct
34 Correct 10 ms 8136 KB Output is correct
35 Correct 1 ms 2128 KB Output is correct
36 Correct 1 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 523 ms 69036 KB Output is correct
2 Correct 1630 ms 314116 KB Output is correct
3 Correct 1630 ms 313856 KB Output is correct
4 Correct 1914 ms 454476 KB Output is correct
5 Correct 1853 ms 454332 KB Output is correct
6 Correct 2226 ms 454340 KB Output is correct
7 Correct 2020 ms 454332 KB Output is correct
8 Correct 972 ms 14440 KB Output is correct
9 Correct 715 ms 14396 KB Output is correct
10 Correct 860 ms 14496 KB Output is correct
11 Correct 1029 ms 14516 KB Output is correct
12 Correct 621 ms 313536 KB Output is correct
13 Correct 931 ms 454424 KB Output is correct
14 Correct 875 ms 454388 KB Output is correct
15 Correct 30 ms 14408 KB Output is correct
16 Correct 23 ms 14532 KB Output is correct
17 Correct 667 ms 303160 KB Output is correct
18 Correct 670 ms 314240 KB Output is correct
19 Correct 650 ms 314792 KB Output is correct
20 Correct 894 ms 454544 KB Output is correct
21 Correct 1033 ms 454404 KB Output is correct
22 Correct 993 ms 454408 KB Output is correct
23 Correct 1004 ms 454552 KB Output is correct
24 Correct 37 ms 14620 KB Output is correct
25 Correct 32 ms 14396 KB Output is correct
26 Correct 43 ms 14460 KB Output is correct
27 Correct 27 ms 14640 KB Output is correct
28 Correct 7 ms 6224 KB Output is correct
29 Correct 17 ms 8144 KB Output is correct
30 Correct 10 ms 8144 KB Output is correct
31 Correct 2 ms 2112 KB Output is correct
32 Correct 2 ms 2128 KB Output is correct
33 Correct 6 ms 3736 KB Output is correct
34 Correct 11 ms 6260 KB Output is correct
35 Correct 8 ms 6224 KB Output is correct
36 Correct 13 ms 8144 KB Output is correct
37 Correct 11 ms 8224 KB Output is correct
38 Correct 11 ms 8212 KB Output is correct
39 Correct 14 ms 8140 KB Output is correct
40 Correct 2 ms 2128 KB Output is correct
41 Correct 2 ms 2128 KB Output is correct
42 Correct 2 ms 2128 KB Output is correct
43 Correct 2 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2640 KB Output is correct
2 Correct 10 ms 6224 KB Output is correct
3 Correct 7 ms 6224 KB Output is correct
4 Correct 10 ms 8144 KB Output is correct
5 Correct 13 ms 8144 KB Output is correct
6 Correct 9 ms 8144 KB Output is correct
7 Correct 9 ms 8144 KB Output is correct
8 Correct 1 ms 2128 KB Output is correct
9 Correct 1 ms 2128 KB Output is correct
10 Correct 1 ms 2128 KB Output is correct
11 Correct 1 ms 2128 KB Output is correct
12 Correct 1 ms 1872 KB Output is correct
13 Correct 1 ms 2128 KB Output is correct
14 Correct 2 ms 2128 KB Output is correct
15 Correct 6 ms 6352 KB Output is correct
16 Correct 10 ms 8144 KB Output is correct
17 Correct 9 ms 8144 KB Output is correct
18 Correct 2 ms 2128 KB Output is correct
19 Correct 2 ms 2128 KB Output is correct
20 Correct 7 ms 6224 KB Output is correct
21 Correct 10 ms 8240 KB Output is correct
22 Correct 11 ms 8144 KB Output is correct
23 Correct 2 ms 2128 KB Output is correct
24 Correct 2 ms 2176 KB Output is correct
25 Correct 4 ms 3664 KB Output is correct
26 Correct 9 ms 6304 KB Output is correct
27 Correct 7 ms 6152 KB Output is correct
28 Correct 10 ms 8144 KB Output is correct
29 Correct 11 ms 8192 KB Output is correct
30 Correct 10 ms 8236 KB Output is correct
31 Correct 9 ms 8144 KB Output is correct
32 Correct 2 ms 2128 KB Output is correct
33 Correct 2 ms 2128 KB Output is correct
34 Correct 2 ms 2128 KB Output is correct
35 Correct 1 ms 2128 KB Output is correct
36 Correct 336 ms 196192 KB Output is correct
37 Correct 542 ms 314836 KB Output is correct
38 Correct 555 ms 313292 KB Output is correct
39 Correct 823 ms 454596 KB Output is correct
40 Correct 849 ms 454400 KB Output is correct
41 Correct 832 ms 454660 KB Output is correct
42 Correct 899 ms 454572 KB Output is correct
43 Correct 20 ms 14384 KB Output is correct
44 Correct 21 ms 14500 KB Output is correct
45 Correct 20 ms 14540 KB Output is correct
46 Correct 20 ms 14520 KB Output is correct
47 Correct 613 ms 313596 KB Output is correct
48 Correct 881 ms 454444 KB Output is correct
49 Correct 850 ms 454464 KB Output is correct
50 Correct 29 ms 14400 KB Output is correct
51 Correct 21 ms 14536 KB Output is correct
52 Correct 558 ms 313600 KB Output is correct
53 Correct 824 ms 454360 KB Output is correct
54 Correct 868 ms 454436 KB Output is correct
55 Correct 21 ms 14416 KB Output is correct
56 Correct 20 ms 14428 KB Output is correct
57 Correct 544 ms 303248 KB Output is correct
58 Correct 556 ms 314212 KB Output is correct
59 Correct 542 ms 314924 KB Output is correct
60 Correct 904 ms 454492 KB Output is correct
61 Correct 877 ms 454304 KB Output is correct
62 Correct 884 ms 454440 KB Output is correct
63 Correct 964 ms 454572 KB Output is correct
64 Correct 31 ms 14388 KB Output is correct
65 Correct 28 ms 14392 KB Output is correct
66 Correct 21 ms 14552 KB Output is correct
67 Correct 25 ms 14436 KB Output is correct
68 Correct 1689 ms 310848 KB Output is correct
69 Correct 1690 ms 314020 KB Output is correct
70 Correct 1714 ms 313944 KB Output is correct
71 Correct 1888 ms 454424 KB Output is correct
72 Correct 2037 ms 454412 KB Output is correct
73 Correct 2003 ms 454496 KB Output is correct
74 Correct 1842 ms 454444 KB Output is correct
75 Correct 912 ms 14400 KB Output is correct
76 Correct 928 ms 14408 KB Output is correct
77 Correct 1083 ms 14520 KB Output is correct
78 Correct 1025 ms 14516 KB Output is correct
79 Correct 971 ms 14416 KB Output is correct
80 Correct 953 ms 14516 KB Output is correct
81 Correct 2 ms 1872 KB Output is correct
82 Correct 1 ms 2128 KB Output is correct
83 Correct 1 ms 2128 KB Output is correct
84 Correct 564 ms 313500 KB Output is correct
85 Correct 836 ms 454636 KB Output is correct
86 Correct 916 ms 454540 KB Output is correct
87 Correct 26 ms 14408 KB Output is correct
88 Correct 25 ms 14536 KB Output is correct
89 Correct 571 ms 313708 KB Output is correct
90 Correct 938 ms 454436 KB Output is correct
91 Correct 860 ms 454340 KB Output is correct
92 Correct 27 ms 14380 KB Output is correct
93 Correct 27 ms 14536 KB Output is correct
94 Correct 8 ms 6352 KB Output is correct
95 Correct 10 ms 8200 KB Output is correct
96 Correct 10 ms 8144 KB Output is correct
97 Correct 1 ms 2128 KB Output is correct
98 Correct 2 ms 2128 KB Output is correct
99 Correct 8 ms 6224 KB Output is correct
100 Correct 14 ms 8164 KB Output is correct
101 Correct 10 ms 8136 KB Output is correct
102 Correct 1 ms 2128 KB Output is correct
103 Correct 1 ms 2128 KB Output is correct
104 Correct 1931 ms 277668 KB Output is correct
105 Correct 2016 ms 313124 KB Output is correct
106 Correct 1983 ms 314756 KB Output is correct
107 Correct 2496 ms 454360 KB Output is correct
108 Correct 2278 ms 454276 KB Output is correct
109 Correct 2302 ms 454444 KB Output is correct
110 Correct 2050 ms 454484 KB Output is correct
111 Correct 847 ms 14512 KB Output is correct
112 Correct 858 ms 14396 KB Output is correct
113 Correct 1077 ms 14484 KB Output is correct
114 Correct 1119 ms 14536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 469 ms 9208 KB Output is correct
2 Correct 973 ms 14408 KB Output is correct
3 Correct 1084 ms 14400 KB Output is correct
4 Correct 966 ms 14380 KB Output is correct
5 Correct 1066 ms 14396 KB Output is correct
6 Correct 1092 ms 14524 KB Output is correct
7 Correct 1008 ms 14408 KB Output is correct
8 Correct 1 ms 1872 KB Output is correct
9 Correct 1 ms 2128 KB Output is correct
10 Correct 2 ms 2128 KB Output is correct
11 Correct 3 ms 2640 KB Output is correct
12 Correct 10 ms 6224 KB Output is correct
13 Correct 7 ms 6224 KB Output is correct
14 Correct 10 ms 8144 KB Output is correct
15 Correct 13 ms 8144 KB Output is correct
16 Correct 9 ms 8144 KB Output is correct
17 Correct 9 ms 8144 KB Output is correct
18 Correct 1 ms 2128 KB Output is correct
19 Correct 1 ms 2128 KB Output is correct
20 Correct 1 ms 2128 KB Output is correct
21 Correct 1 ms 2128 KB Output is correct
22 Correct 1 ms 1872 KB Output is correct
23 Correct 1 ms 2128 KB Output is correct
24 Correct 2 ms 2128 KB Output is correct
25 Correct 6 ms 6352 KB Output is correct
26 Correct 10 ms 8144 KB Output is correct
27 Correct 9 ms 8144 KB Output is correct
28 Correct 2 ms 2128 KB Output is correct
29 Correct 2 ms 2128 KB Output is correct
30 Correct 7 ms 6224 KB Output is correct
31 Correct 10 ms 8240 KB Output is correct
32 Correct 11 ms 8144 KB Output is correct
33 Correct 2 ms 2128 KB Output is correct
34 Correct 2 ms 2176 KB Output is correct
35 Correct 4 ms 3664 KB Output is correct
36 Correct 9 ms 6304 KB Output is correct
37 Correct 7 ms 6152 KB Output is correct
38 Correct 10 ms 8144 KB Output is correct
39 Correct 11 ms 8192 KB Output is correct
40 Correct 10 ms 8236 KB Output is correct
41 Correct 9 ms 8144 KB Output is correct
42 Correct 2 ms 2128 KB Output is correct
43 Correct 2 ms 2128 KB Output is correct
44 Correct 2 ms 2128 KB Output is correct
45 Correct 1 ms 2128 KB Output is correct
46 Correct 336 ms 196192 KB Output is correct
47 Correct 542 ms 314836 KB Output is correct
48 Correct 555 ms 313292 KB Output is correct
49 Correct 823 ms 454596 KB Output is correct
50 Correct 849 ms 454400 KB Output is correct
51 Correct 832 ms 454660 KB Output is correct
52 Correct 899 ms 454572 KB Output is correct
53 Correct 20 ms 14384 KB Output is correct
54 Correct 21 ms 14500 KB Output is correct
55 Correct 20 ms 14540 KB Output is correct
56 Correct 20 ms 14520 KB Output is correct
57 Correct 613 ms 313596 KB Output is correct
58 Correct 881 ms 454444 KB Output is correct
59 Correct 850 ms 454464 KB Output is correct
60 Correct 29 ms 14400 KB Output is correct
61 Correct 21 ms 14536 KB Output is correct
62 Correct 558 ms 313600 KB Output is correct
63 Correct 824 ms 454360 KB Output is correct
64 Correct 868 ms 454436 KB Output is correct
65 Correct 21 ms 14416 KB Output is correct
66 Correct 20 ms 14428 KB Output is correct
67 Correct 544 ms 303248 KB Output is correct
68 Correct 556 ms 314212 KB Output is correct
69 Correct 542 ms 314924 KB Output is correct
70 Correct 904 ms 454492 KB Output is correct
71 Correct 877 ms 454304 KB Output is correct
72 Correct 884 ms 454440 KB Output is correct
73 Correct 964 ms 454572 KB Output is correct
74 Correct 31 ms 14388 KB Output is correct
75 Correct 28 ms 14392 KB Output is correct
76 Correct 21 ms 14552 KB Output is correct
77 Correct 25 ms 14436 KB Output is correct
78 Correct 1689 ms 310848 KB Output is correct
79 Correct 1690 ms 314020 KB Output is correct
80 Correct 1714 ms 313944 KB Output is correct
81 Correct 1888 ms 454424 KB Output is correct
82 Correct 2037 ms 454412 KB Output is correct
83 Correct 2003 ms 454496 KB Output is correct
84 Correct 1842 ms 454444 KB Output is correct
85 Correct 912 ms 14400 KB Output is correct
86 Correct 928 ms 14408 KB Output is correct
87 Correct 1083 ms 14520 KB Output is correct
88 Correct 1025 ms 14516 KB Output is correct
89 Correct 971 ms 14416 KB Output is correct
90 Correct 953 ms 14516 KB Output is correct
91 Correct 2 ms 1872 KB Output is correct
92 Correct 1 ms 2128 KB Output is correct
93 Correct 1 ms 2128 KB Output is correct
94 Correct 564 ms 313500 KB Output is correct
95 Correct 836 ms 454636 KB Output is correct
96 Correct 916 ms 454540 KB Output is correct
97 Correct 26 ms 14408 KB Output is correct
98 Correct 25 ms 14536 KB Output is correct
99 Correct 571 ms 313708 KB Output is correct
100 Correct 938 ms 454436 KB Output is correct
101 Correct 860 ms 454340 KB Output is correct
102 Correct 27 ms 14380 KB Output is correct
103 Correct 27 ms 14536 KB Output is correct
104 Correct 8 ms 6352 KB Output is correct
105 Correct 10 ms 8200 KB Output is correct
106 Correct 10 ms 8144 KB Output is correct
107 Correct 1 ms 2128 KB Output is correct
108 Correct 2 ms 2128 KB Output is correct
109 Correct 8 ms 6224 KB Output is correct
110 Correct 14 ms 8164 KB Output is correct
111 Correct 10 ms 8136 KB Output is correct
112 Correct 1 ms 2128 KB Output is correct
113 Correct 1 ms 2128 KB Output is correct
114 Correct 523 ms 69036 KB Output is correct
115 Correct 1630 ms 314116 KB Output is correct
116 Correct 1630 ms 313856 KB Output is correct
117 Correct 1914 ms 454476 KB Output is correct
118 Correct 1853 ms 454332 KB Output is correct
119 Correct 2226 ms 454340 KB Output is correct
120 Correct 2020 ms 454332 KB Output is correct
121 Correct 972 ms 14440 KB Output is correct
122 Correct 715 ms 14396 KB Output is correct
123 Correct 860 ms 14496 KB Output is correct
124 Correct 1029 ms 14516 KB Output is correct
125 Correct 621 ms 313536 KB Output is correct
126 Correct 931 ms 454424 KB Output is correct
127 Correct 875 ms 454388 KB Output is correct
128 Correct 30 ms 14408 KB Output is correct
129 Correct 23 ms 14532 KB Output is correct
130 Correct 667 ms 303160 KB Output is correct
131 Correct 670 ms 314240 KB Output is correct
132 Correct 650 ms 314792 KB Output is correct
133 Correct 894 ms 454544 KB Output is correct
134 Correct 1033 ms 454404 KB Output is correct
135 Correct 993 ms 454408 KB Output is correct
136 Correct 1004 ms 454552 KB Output is correct
137 Correct 37 ms 14620 KB Output is correct
138 Correct 32 ms 14396 KB Output is correct
139 Correct 43 ms 14460 KB Output is correct
140 Correct 27 ms 14640 KB Output is correct
141 Correct 7 ms 6224 KB Output is correct
142 Correct 17 ms 8144 KB Output is correct
143 Correct 10 ms 8144 KB Output is correct
144 Correct 2 ms 2112 KB Output is correct
145 Correct 2 ms 2128 KB Output is correct
146 Correct 6 ms 3736 KB Output is correct
147 Correct 11 ms 6260 KB Output is correct
148 Correct 8 ms 6224 KB Output is correct
149 Correct 13 ms 8144 KB Output is correct
150 Correct 11 ms 8224 KB Output is correct
151 Correct 11 ms 8212 KB Output is correct
152 Correct 14 ms 8140 KB Output is correct
153 Correct 2 ms 2128 KB Output is correct
154 Correct 2 ms 2128 KB Output is correct
155 Correct 2 ms 2128 KB Output is correct
156 Correct 2 ms 2128 KB Output is correct
157 Correct 1931 ms 277668 KB Output is correct
158 Correct 2016 ms 313124 KB Output is correct
159 Correct 1983 ms 314756 KB Output is correct
160 Correct 2496 ms 454360 KB Output is correct
161 Correct 2278 ms 454276 KB Output is correct
162 Correct 2302 ms 454444 KB Output is correct
163 Correct 2050 ms 454484 KB Output is correct
164 Correct 847 ms 14512 KB Output is correct
165 Correct 858 ms 14396 KB Output is correct
166 Correct 1077 ms 14484 KB Output is correct
167 Correct 1119 ms 14536 KB Output is correct
168 Correct 1 ms 1872 KB Output is correct
169 Correct 1053 ms 101792 KB Output is correct
170 Correct 1743 ms 312212 KB Output is correct
171 Correct 2023 ms 313364 KB Output is correct
172 Correct 2274 ms 454396 KB Output is correct
173 Correct 2080 ms 454476 KB Output is correct
174 Correct 2310 ms 454448 KB Output is correct
175 Correct 2152 ms 454648 KB Output is correct
176 Correct 975 ms 14380 KB Output is correct
177 Correct 965 ms 14384 KB Output is correct
178 Correct 1022 ms 14524 KB Output is correct
179 Correct 1192 ms 14516 KB Output is correct