백준(알고리즘)

반응형
백준(알고리즘)

[이것이 코딩 테스트다 with 파이썬] 큰 수의 법칙

문제 여기서 큰 수의 법칙이란 다양한 수로 이뤄진 배열이 있을 때 주어진 수들을 M번 더해 가장 큰 수를 만드는 법칙 단, 배열의 특정한 인덱스(번호)에 해당하는 수가 연속해서 K번을 초과할 수는 없음 입력 조건 첫째 줄에 N(2

백준(알고리즘)

백준 1267 핸드폰 요금

www.acmicpc.net/problem/1267 1267번: 핸드폰 요금 동호가 저번 달에 이용한 통화의 개수 N이 주어진다. N은 20보다 작거나 같은 자연수이다. 둘째 줄에 통화 시간 N개가 주어진다. 통화 시간은 10,000보다 작거나 같은 자연수이다. www.acmicpc.net #include using namespace std; int main(void) { int n, input, min = 0, young = 0; cin >> n; for (int i = 0; i > input; young += (input / 30 + 1) * 10; min += (input / 60 + 1) * 15; } if (min < young) cout

백준(알고리즘)

백준 1094 막대기

www.acmicpc.net/problem/1094 1094번: 막대기 지민이는 길이가 64cm인 막대를 가지고 있다. 어느 날, 그는 길이가 Xcm인 막대가 가지고 싶어졌다. 지민이는 원래 가지고 있던 막대를 더 작은 막대로 자른다음에, 풀로 붙여서 길이가 Xcm인 막대 www.acmicpc.net #include using namespace std; int main() { /* 막대기가 나뉠수있는건 1,2,4,8,16,32 */ int x; cin >> x; int cnt = 0; for (int j = 0; j < 7; j++) { if (x & 1

백준(알고리즘)

백준 1613 역사

www.acmicpc.net/problem/1613 1613번: 역사 첫째 줄에 첫 줄에 사건의 개수 n(400 이하의 자연수)과 알고 있는 사건의 전후 관계의 개수 k(50,000 이하의 자연수)가 주어진다. 다음 k줄에는 전후 관계를 알고 있는 두 사건의 번호가 주어진다. www.acmicpc.net #include using namespace std; int arr[401][401]; //bool로 해보려고 했는데 이번경우는 출력이 3개나되서 int main() { cin.tie(NULL); ios::sync_with_stdio(false); int n, k; cin >> n >> k; int tmp1, tmp2; for (int i = 1; i > tmp1 >> tmp2; arr[tmp1][tmp..

백준(알고리즘)

백준 14889 스타트와 링크 (비트마스크)

www.acmicpc.net/problem/14889 14889번: 스타트와 링크 예제 2의 경우에 (1, 3, 6), (2, 4, 5)로 팀을 나누면 되고, 예제 3의 경우에는 (1, 2, 4, 5), (3, 6, 7, 8)로 팀을 나누면 된다. www.acmicpc.net #include #include #include using namespace std; vector start; vector link; int arr[21][21]; int main() { int n; cin >> n; for (int i = 0; i > arr[i][j]; } } //입력 int maxx = 9999999; //0010 for (in..

백준(알고리즘)

백준 11723 집합

www.acmicpc.net/problem/11723 11723번: 집합 첫째 줄에 수행해야 하는 연산의 수 M (1 ≤ M ≤ 3,000,000)이 주어진다. 둘째 줄부터 M개의 줄에 수행해야 하는 연산이 한 줄에 하나씩 주어진다. www.acmicpc.net #include #include using namespace std; int main() {cin.tie(NULL); ios::sync_with_stdio(false); int n; cin >> n; string input; int tmp; int bit = 0; for (int i = 0; i > input; if (input[1] == 'd')//add { ci..

백준(알고리즘)

백준 2217 로프

www.acmicpc.net/problem/2217 2217번: 로프 N(1 ≤ N ≤ 100,000)개의 로프가 있다. 이 로프를 이용하여 이런 저런 물체를 들어올릴 수 있다. 각각의 로프는 그 굵기나 길이가 다르기 때문에 들 수 있는 물체의 중량이 서로 다를 수도 있다. 하 www.acmicpc.net #include #include #include using namespace std; int main() { int ropecnt; cin >> ropecnt; vectorarr(ropecnt+1,0); int tmp; for (int i = 1; i >arr[i]; } sort(arr.begin(), arr.end()); int maxx = -1; for (int i =1;i

백준(알고리즘)

백준 11404 플로이드

www.acmicpc.net/problem/11404 11404번: 플로이드 첫째 줄에 도시의 개수 n이 주어지고 둘째 줄에는 버스의 개수 m이 주어진다. 그리고 셋째 줄부터 m+2줄까지 다음과 같은 버스의 정보가 주어진다. 먼저 처음에는 그 버스의 출발 도시의 번호가 www.acmicpc.net #include #include #include using namespace std; #define INF 10000001 vector arr(101, vector (101, INF)); int main() { int n, m; cin >> n >> m; int a, b, c; for (int i = 1; i > a >> b >> c; if(arr[a][b]>c) arr[a][b] = c; ..

백준(알고리즘)

백준 18353 병사 배치하기

www.acmicpc.net/problem/18353 18353번: 병사 배치하기 첫째 줄에 N이 주어진다. (1 ≤ N ≤ 2,000) 둘째 줄에 각 병사의 전투력이 공백을 기준으로 구분되어 차례대로 주어진다. 각 병사의 전투력은 10,000,000보다 작거나 같은 자연수이다. www.acmicpc.net #include #include using namespace std; int power; int arr[2][2001]; int main() { cin.tie(NULL); int n; cin >> n; for (int i = 0; i > arr[0][i]; arr[1][i] = 1; } int maxx=-99; for (int i = 0; i < n; i++) { int..

백준(알고리즘)

백준 1764 듣보잡

www.acmicpc.net/problem/1764 #include #include #include using namespace std; int main(void) { cin.tie(NULL); int n, m; cin >> n >> m; vector arr; vector brr; string tmp; for (int i = 0; i > tmp; arr.push_back(tmp); tmp.clear(); } sort(arr.begin(), arr.end()); //정렬 for (int j = 0; j > tmp; if (binary_search(arr.begin(), arr.end(), tmp)) //이진탐색으로 입력받은 두번째값을 체크 { b..

반응형
빡상이
'백준(알고리즘)' 카테고리의 글 목록