갬장장이
'software engineering/PS' 카테고리의 글 목록 (2 Page)

software engineering/PS

software engineering/PS

boj 7569

#include #include using namespace std; int graph[100][100][100]; //rch int dir[6][3]{ {1,0,0},{0,1,0},{-1,0,0},{0,-1,0},{0,0,1},{0,0,-1} }; int R, C, H; int ret = 1; queue q; void bfs() { while (!q.empty()) { int size = q.size(); for (int i = 0; i < size;i++) { int r = q.front().first.first; int c = q.front().first.second; int h = q.front().second; q.pop(); for (int j = 0; j < 6; j++) { int nr =..

software engineering/PS

boj 10800

#include #include using namespace std; int n; int C[200020],S[2020]; pair arr[200020]; int ans[200020]; int main() { scanf(" %d", &n); for (int i = 0; i < n; i++) { int w, c; scanf(" %d %d", &c, &w); arr[i] = { {w,c-1},i }; } sort(arr, arr + n); int sum = 0; for (int i = 0; i < n; i++) { int weight = arr[i].first.first; int color = arr[i].first.second; int idx = arr[i].second; C[color] += weight..

software engineering/PS

boj 1912

#include #include #include using namespace std; // 누적합 문제 int N; int dp[100001]; // dp[i]는 i번 수를 무조건 사용하는 최대 연속합 int arr[100001]; // 수열 int ret = INT_MIN; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; for(int i=1;i> arr[i]; dp[i] = max(dp[i-1]+arr[i], arr[i]); ret = max(ret, dp[i]); } cout

software engineering/PS

boj 12851

주요 포인트: 1) 입력이 1 4 일 경우 1*2와 1+1을 다른 경우로 구분해야 하기 때문에 visited를 true로 바꿔주는 시점이 큐에서 pop을 한 이후가 되야 한다. 2) 턴수를 기록하기 위해서 queue를 사용하면 편하고, 다른 사람들 풀이도 대부분 이러한 형태이다. 그러나 더 까다롭지만 배열을 써도 풀 수 있다. 이를 위해선 한 번 이동할 때 최대크기 체크( N >> K; memset(turns, 0, sizeof(turns)); memset(visited, false, sizeof(visited)); bfs(); cout

software engineering/PS

boj 14891

deque를 사용 #include #include #include #include #include using namespace std; vector gear(5); int rotation[5]; bool check[5]; int k; void setRotation(int g, int d) { rotation[g] = d; check[g] = true; if (g - 1 > 0 && !check[g - 1]) { if (d == 0) setRotation(g - 1, 0); else if (gear[g][6] == gear[g - 1][2]) setRotation(g - 1, 0); else setRotation(g - 1, -d); } if (g + 1 k; int g, d; while (k--) { c..

software engineering/PS

boj 1202

#include #include #include #include using namespace std; const int MAX = 300000; int N, K; int bag[MAX]; pair jewelry[MAX]; priority_queue pq; int main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> K; for (int i = 0; i > jewelry[i].first >> jewelry[i].second; for (int i = 0; i > bag[i]; //보석(무게 기준)과 가방 오름차순 정렬 sort(jewelry, jewelry + N);..

software engineering/PS

프로그래머스 <정수 삼각형>

#include #include #include using namespace std; vector maxDist; void getMaxDist(int row, int col) { maxDist[row][col] = max(maxDist[row][col] + maxDist[row-1][col], maxDist[row][col] + maxDist[row-1][col-1]); return; } int solution(vector triangle) { int answer = 0; for (int i = 0; i < triangle.size(); ++i) { vector row; row.push_back(0); for (int j = 0; j < triangle[i].size(); ++j) { row.push_b..

software engineering/PS

프로그래머스 <기능개발>

#include #include #include #include #include using namespace std; vector solution(vector progresses, vector speeds) { vector answer; queue days; days.push(ceil((100 - progresses[0]) / (float)speeds[0])); for (int i = 1; i < progresses.size(); ++i) { int curr = ceil((100 - progresses[i]) / (float)speeds[i]); if (curr