https://www.acmicpc.net/problem/13300
각 학년, 성별 당 배열을 할당해서 풀어주어서 분기로 방 개수를 할당해주면 되는 문제였다.
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// 저장할 배열 : 2는 성별, 6은 학년
int arr[2][7] = {0};
int n, k, ans = 0;
// n은 참여 학생 수, k는 한 방에 최대 인원 수
cin >> n >> k;
int temp1, temp2;
for (int i = 0; i < n; i++) {
cin >> temp1 >> temp2;
arr[temp1][temp2]++;
}
for (int i = 0; i < 2; i++) {
for (int j = 1; j <= 6; j++) {
if (arr[i][j] % k == 0)
ans += arr[i][j] / k;
else
ans += arr[i][j] / k + 1;
}
}
cout << ans;
return 0;
}
'PS > BOJ' 카테고리의 다른 글
[백준] 1919. 애너그램 만들기(c++) (0) | 2025.01.21 |
---|---|
[백준] 11328. Strfry(c++) (0) | 2025.01.19 |
[백준] 10807. 개수 세기(c++) (0) | 2025.01.19 |
[백준] 3273. 두 수의 합(c++) (0) | 2025.01.16 |
[백준] 1475. 방 번호(c++) (0) | 2025.01.15 |