Skip to content

Commit 93e8373

Browse files
ing-eokingbugs-bot
authored andcommitted
๐Ÿœ Study: ํƒ‘ (#41)
1 parent a4280d3 commit 93e8373

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

โ€Žing-eoking/ํƒ‘.ccโ€Ž

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <iostream>
2+
#include <vector>
3+
4+
using namespace std;
5+
6+
int main (int argc, char **argv) {
7+
int N, tower;
8+
vector<pair<int, int>> stack;
9+
scanf("%d", &N);
10+
for (int i = 1; i <= N; i++) {
11+
scanf("%d", &tower);
12+
while (!stack.empty() && stack.back().first < tower) stack.pop_back();
13+
printf("%d ",stack.empty() ? 0 : stack.back().second);
14+
stack.push_back({tower, i});
15+
}
16+
}

0 commit comments

Comments
ย (0)