Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- c++
- 로블록스 script local script 차이
- 유니티 꿀팁
- 2644번
- bfs
- 1699번
- 백준 17299번 c++
- 백준 11726번 C++
- UML Diagram 정리
- 백준 2225번 c++
- 차이
- 코드
- transform.position
- 유니티
- 배열 stack overflow
- 풀이
- 백준 10799번 c++
- 프로그래머스 단체사진 찍기 C++
- TOPCIT 후기
- 백준 2193번 c++
- 프로그래머스 가장 큰 수 C++
- 백준
- long int 의 차이
- 유니티 Rigidbody 이동
- 유니티 LTS
- rigidbody.position
- rigidbody.Moveposition
- 플레이어 이동
- 백준 10844번 c++
- TOPCIT 문제 유형
Archives
- Today
- Total
Kiki Devlog
[17298번][골4] 오큰수 본문
728x90
갑자기 골드 난이도가 나와서 시간제한에 걸려 머리 싸메다가 풀이법을 보고 풀었다.
내 코드
#include<iostream>
#include <string>
#include <deque>
#include <stack>
using namespace std;
int main() {
deque<int> d;
deque<int> ans;
stack<int> s;
int totalNum = 0;
int num;
cin >> totalNum;
for (int i = 0; i < totalNum; i++) {
cin>> num;
d.push_back(num);
}
for (int i = totalNum-1; i >=0; i--) {
while (!s.empty() && d[i] >= s.top())
s.pop();
if (s.empty())
ans.push_front(-1);
else {
ans.push_front(s.top());
}
s.push(d[i]);
}
for (int i = 0; i < ans.size(); i++)
cout << ans[i] << " ";
return 0;
}
'Coding Test > 백준' 카테고리의 다른 글
[실3][C++] 백준 1935번 후위 표기식 2 (소숫점 제한) (0) | 2022.05.28 |
---|---|
[17299번][골3] 오등큰수 (배열 stack overflow 해결법) (0) | 2022.03.17 |
[10799번][실3] 쇠막대기 (0) | 2022.03.15 |
[17413번][실3] 단어 뒤집기2 (0) | 2022.03.14 |
[1158번][실5] 요세푸스 문제 (0) | 2022.03.12 |
Comments