본문 바로가기

반응형

전체 글

(168)
완주하지 못한 선수 123456789101112131415161718192021#include #include #include using namespace std; string solution(vector participant, vector completion) { string answer = ""; sort(participant.begin(), participant.end()); sort(completion.begin(), completion.end()); int answerIdx; for(int i = 0, j = 0; i
Jumping on the Clouds 1234567891011121314151617// Complete the jumpingOnClouds function below.int jumpingOnClouds(vector c) { int count = 0; int i = 0; while(1) { if(i + 1 >= c.size()) break; if(c[i + 2] != 1) { count++; i += 2; } else if (c[i + 1] == 0){ count++; i++; } } return count;}Colored by Color Scriptercs 예시가 그림까지 너무 잘 나와있어서 모두 가져왔다. 문제는 구름을 뛰어넘는 것을 계산하는 문제이다. 하지만 구름의 종류가 두가지이다. 하나는 일반 구름, 다른 하나는 천둥을 포함하고 있는..
2751번 수 정렬하기2 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758#include #include using namespace std; #define MAX 1000000 void merge(int arr[], int mid, int low, int high) { int temp[MAX]; int i,j,k; for(i = low; i
2750번 수 정렬하기 12345678910111213141516171819202122232425262728293031#include #include #include using namespace std; int main() { int n; scanf("%d", &n); vector v(n); for(int i = 0; i
6064번 카잉 달력 123456789101112131415161718192021222324252627282930#include using namespace std; int main() { int t, M, N, x, y; scanf("%d", &t); while(t--) { scanf("%d %d %d %d", &M, &N, &x, &y); int tempX = 0, tempY = 0; int count = 1; bool isExist = true; while(!(tempX * M + x == tempY * N + y)) { if(tempX * M + x > M * N || tempY * N + y > M * N) { isExist = false; break; } if(tempX * M + x > tempY * N + y)..
Equalize the Array 12345678910111213141516171819202122232425262728// Complete the equalizeArray function below.int equalizeArray(vector arr) { int maxCount = 1; int maxNum = arr[0]; int tempCount = 1; int tempMax = arr[0]; sort(arr.begin(), arr.end()); for(int i = 0; i = maxCount) { maxNum = tempMax; maxCount = tempCount; } } else { tempCount = 1; tempMax = arr[i + 1]; } } return arr.size() - maxCount; } Colored b..
ACM ICPC Team 123456789101112131415161718192021222324252627282930// Complete the acmTeam function below.vector acmTeam(vector topic) { int maxCount = 0, maxTeams = 0; for(int i = 0; i
1475번 방 번호 12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include using namespace std; int numbers[10] = { 0,}; int main(){ int n; scanf("%d", &n); if (n == 0) { cout