정렬(Sort)
-
백준 10989번: 수 정렬하기 3정렬(Sort) 2018. 7. 3. 10:26
https://www.acmicpc.net/problem/10989 1. 문제N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성하시오. 2. 알고리즘키워드 - 정렬메모리 제약사항이 8MB 이고 들어오는 입력으로 들어오는 숫자가 10000000 개 임으로 일반적인 sort 함수를 사용해서는 풀 수 없다.입력으로 들어오는 숫자의 상한 값이 10000 이상 입력되지 않기 때문에 모든 수를 메모리에 적제할 필요는 없다. 10000 * 4 = 4만 바이트에 용량으로 처리가 가능하다. 3. 코드 1234567891011121314151617181920212223242526272829#include #include // min#include #include #include #include typed..
-
백준 11004번: K번째 수정렬(Sort) 2018. 6. 24. 13:19
https://www.acmicpc.net/problem/11004 1. 문제수 N개 A1, A2, ..., AN이 주어진다. A를 오름차순 정렬했을 때, 앞에서부터 K번째 있는 수를 구하는 프로그램을 작성하시오. 2. 알고리즘키워드 - 정렬 3. 코드 1234567891011121314151617181920212223242526272829303132333435363738394041#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define MAX_SIZE 100#define INF 0x7fffffff /*..
-
Codeforces Round #489 (Div. 2) : A. Nastya and an Array정렬(Sort) 2018. 6. 19. 10:45
http://codeforces.com/contest/992/problem/A 1. 문제A. Nastya and an Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties: In one second we can add an ..
-
프로그래머스 Level1: 나누어 떨어지는 숫자 배열정렬(Sort) 2018. 6. 14. 17:47
https://programmers.co.kr/learn/courses/30/lessons/12910 1. 문제 요약 입력되는 정수와 나눗셈 값으로 나누어 지는 값을 array 배열에 넣어 반환 하는 문제 2. 알고리즘 배열을 정렬 한다. 나누어서 나머지가 0 인 수만 array 에 담는다. 3. 코드 12345678910111213141516171819202122#include #include #include using namespace std; vector solution(vector arr, int divisor) { vector answer; sort(arr.begin(), arr.end()); const int size = arr.size(); for(int i=0; i
-
백준 2959번: 거북이정렬(Sort) 2018. 6. 13. 10:37
백준 온라인 저지(BOJ) 2959번 문제 https://www.acmicpc.net/problem/2959 1. 문제 요약 숫자 4개가 주어졌을 때(순서 무관) 그 숫자만큼 이동 후 오른쪽으로 90도 회전하여 만들어지는 직사각형의 최대 넓이는? 2. 알고리즘 직사각형은 변 2개가 있어야 만들어진다. 작은 것 / 큰 것이 있을 때 작은 것의 길이만큼이 해당 변의 길이가 된다. A ≤ B ≤ C ≤ D로 있으면 이 때 가능한 값은 AB or AC이므로 최대 넓이는 AC이다. 3. 코드 123456789101112131415161718192021222324252627#include #include // min#include #include #include #include #include #include #i..