#include <bits/stdc++.h>
using namespace std;
int main()
{
priority_queue <int> q;
q.push(3);
q.push(5);
q.push(7);
q.push(9);
q.push(2);
cout << q.top() << endl;
q.pop();
cout << q.top() << endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
priority_queue <int> q;
q.push(-3);
q.push(-5);
q.push(-7);
q.push(-9);
q.push(-2);
cout << -q.top() << endl;
q.pop();
cout << -q.top() << endl;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main()
{
priority_queue <int, vector<int>, greater<int>> q;
q.push(3);
q.push(5);
q.push(7);
q.push(9);
q.push(2);
cout << q.top() << endl;
q.pop();
cout << q.top() << endl;
return 0;
}
'정보올림피아드-KOI > 알고리즘 트레이닝' 카테고리의 다른 글
[이코테] 곱하기 혹은 더하기 (0) | 2020.12.14 |
---|---|
[이코테] 1이 될때까지 (0) | 2020.12.14 |
힙 정렬 - Heap sort (0) | 2020.04.08 |
2장. 프로그래밍 기법 (2.2 재귀적 알고리즘), Recursion (0) | 2020.03.22 |
2장. 프로그래밍 기법 (2.1 언어적 특성) (0) | 2020.03.22 |