| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- Computer science
- 스택
- vector
- 구현
- 정석
- 오에스
- 컴공과
- coding
- Operating System
- 너비우선탐색
- 코딩
- 브루트포스
- Stack
- OS
- 알고리즘
- 컴공
- 개발
- 그래프
- 백준
- 문제풀이
- 북리뷰
- 정석학술정보관
- 오퍼레이팅시스템
- bfs
- cs
- c++
- DP
- 코테
- 자료구조
- 컴퓨터공학과
- Today
- Total
목록priorityqueue (2)
Little Jay
greedy한 문제였다 단순히 닭이 소의 시간 안에 들어있는지 아닌지를 파악해주면 되는 문제라 쉬워보였지만, 소를 priority queue로 정렬하는데에 있어서 시작시간만을 기준으로 정렬하면 틀리는 문제였다. priority queue의 정렬 함수를 구현하는 것이 결국 관건이었던 문제이다 #include #define endl '\n' using namespace std; int c, n; struct comp { bool operator()(pair a, pair b) { if (a.second != b.second) return a.second > b.second; return a.first > b.first; } }; vector chicken; priority_queue cow; int main..
while문의 조건을 짜는게 많이 까다로웠던 문제 #include #define endl '\n' using namespace std; int N; priority_queue min_heap; priority_queue max_heap; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> N; while(N--) { int score; cin >> score; if (min_heap.empty() || max_heap.empty()) { max_heap.push(score); } else { if (score = min_heap.top()) min_heap.push(score); else max_heap.push(score)..