Recent Posts
«   2024/11   »
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
Today
Total
관리 메뉴

Try

[Programmers/C++] 숫자 게임 본문

Algorithm/Programmers

[Programmers/C++] 숫자 게임

HAS3ONG 2019. 3. 26. 23:52

출처

https://programmers.co.kr/learn/courses/30/lessons/12987


소스

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
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int solution(vector<int> A, vector<int> B) {
    int answer = 0;
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int res1 = 0;
    int k = 0;
    for(int i = 0; i< A.size(); i++){
        for(int j = k; j < A.size(); j++){
            if (A[i] < B[j]){
                res1++;
                k = j + 1;
                break;
            }
        }
    }
    answer = res1;
    return answer;
}
cs


'Algorithm > Programmers' 카테고리의 다른 글

[Programmers/C++] 스킬트리  (0) 2019.03.27
[Programmers/Python] 숫자게임  (0) 2019.03.26
[Programmers/Python] 저울  (0) 2019.03.24
[Programmers/C++] 저울  (0) 2019.03.24
[Programmers/Python] 타일 장식물  (0) 2019.03.23
Comments