#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int arr[100001];
int ind;
int max;
int type;
int num;
int cnt;
max = -1;
scanf("%d", &cnt);
while(cnt--) {
scanf("%d", &type);
if(type == 1){
scanf("%d", &arr[ind]);
if(max < arr[ind])
max = arr[ind];
ind++;
} else if(type == 2) {
ind--;
max = -1;
for(int i = 0 ; i < ind ; i++) {
if(max < arr[i]) {
max = arr[i];
}
}
} else if(type == 3) {
printf("%d\n", max);
}
}
return 0;
}
감사해여... 참고가 많이 됐어요
나 너무 정석으로 해서 문제가 된거 같음.
문제가, 그냥 스택무시하고 풀면 풀리는 거였네요
시간제한이 걸리는 일반적인 이유가 너무 복잡하게 풀어서.. 이므로.. 문제를 최대한 단순하게 보고 풀면 풀리는 경우가 많죠
그러게 말이예요, 스택코드를 배운게 있는데 , 그 코드가 쫌 좋아서 왠만한건 다해결가능한데.. 시간제한에 걸리다니 말도안되요
란씨맨//되요->돼요 (되어 = 돼임) [리듬 맞춤법 봇♬]
란씨맨//왠만->웬만 (왠지 빼고 웬임) [리듬 맞춤법 봇♬]