본문 바로가기

분류 전체보기144

[프로그래머스] 순위 검색 #include #define fastio cin.tie(0)->sync_with_stdio(0)#define long long size_tusing namespace std;map> scores;void storeScore(vector> &tmp, int score) { string c1, c2, c3, c4; for (int i=0; i solution(vector info, vector query){ vector answer; vector> tmp(4, vector(2,"-")); for(int i=0; i>s){ if(idx>s){ if(s=="and") continue; if(idx 참고https://c.. 2025. 4. 12.
[백준] 2437번 저울 #include #define fastio cin.tie(0)->sync_with_stdio(0)#define long long size_tusing namespace std;int N;int arr[1000];int main(){ cin>>N; for(int i=0; i>arr[i]; } sort(arr,arr+N); int res = 1; for(int i=0; ires){ break; } res+=arr[i]; } cout[풀이]res: 지금까지 만들 수 있는 모든 연속적인 (자연수의 범위의 끝 + 1) 이다.arr[i]가 res보다 작거나 같으면 → 이 수를 써서 기존 만들 수 있는 범위를 더 확장할 수.. 2025. 4. 10.
[프로그래머스] 서버 증설 #include #define fastio cin.tie(0)->sync_with_stdio(0)#define long long size_tusing namespace std;int solution(int players[], size_t players_len, int m, int k) { int answer = 0; int server[1000] = {0}; // 충분한 크기 가정 for (size_t i = 0; i capacity) { int need = players[i] - capacity; int extra = (need + m - 1) / m; // 올림 처리 for (int j = 0; j 사람이 m명 증가 시 서버.. 2025. 4. 9.
[프로그래머스] 단체 사진 찍기 #include #define fastio cin.tie(0)->sync_with_stdio(0)#define MAX 5using namespace std;int answer;bool select[8];char ItoC[8] = {'A','C','F','J','M','N','R','T'};void DFS(int cnt, char arr[], vector data){ if(cnt == 8) { for(int i=0; i= dist) return; if(cond == '>' && abs(idx-iidx) data){ fastio; char arr[8] = {NULL, }; answer = 0; DFS(0, arr, data); retur.. 2025. 4. 8.