티스토리 뷰

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
using namespace std;
 
int countLine(int N);
 
class Line {
private:
    int A, B;
public:
    void setLine(int A, int B) {
        this->= A;
        this->= B;
    }
    bool operator<(Line line) {
        if (this->< line.A)
            return true;
        return false;
    }
    int getB() {
        return this->B;
    }
};
 
int main() {
    int N;
    scanf("%d"&N);
    printf("%d\n", countLine(N));
}
 
int countLine(int N) {
    int* ary = new int[N] {0, };
    Line* line = new Line[N];
    for (int i = 0; i < N; i++) {
        int A, B;
        scanf("%d %d"&A, &B);
        line[i].setLine(A, B);
    }
    sort(line, &line[N]);
 
    for (int i = 0; i < N; i++)
        for (int j = i + 1; j < N; j++)
            if (line[i].getB() < line[j].getB() && ary[i] == ary[j])
                ary[j]++;
    int max = 0;
    for (int i = 0; i < N; i++)
        if (max < ary[i])
            max = ary[i];
 
    delete[] line;
    delete[] ary;
    return N - (max + 1);
}
cs
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함