๐Ÿ“– Coding Study/Algorithm 3

๋ฐฑ์ค€ 10828 "์Šคํƒ" ํŒŒ์ด์ฌ ๋ฌธ์ œํ’€์ด

์ง€๋‚œํ•™๊ธฐ ์ˆ˜๊ฐ•ํ–ˆ๋˜ ์ž๋ฃŒ๊ตฌ์กฐ ๊ฐ•์˜์—์„œ ๋ฐฐ์šด ๋‚ด์šฉ์„ ์ด์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด๋ณด์•˜๋‹ค stack = [] high = -1 def push(num) : global high stack.append(num) high += 1 def top() : if len(stack) == 0 : print(-1) else : print(stack[high]) def userDefPop() : global high if high == -1 : print(-1) else : print(stack.pop()) high -= 1 n = int(input()) for _ in range(n): command = input() if "push" in command : command = command.split() push(command[..

์ฝ”๋“œ ์‹คํ–‰ ์‹œ๊ฐ„ ๋‹จ์ถ• "ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);"

๋ฐฑ์ค€ 10871๋ฒˆ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ๋Š”๋ฐ, ์‹œ๊ฐ„์ด 4ms๋กœ ๋‚˜์™”๋‹ค. ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์˜ ์‹œ๊ฐ„์„ ๋ณด๋‹ˆ 4ms๋„ ์žˆ์—ˆ์ง€๋งŒ 0ms๊ฐ€ ๋งŽ์•˜๋‹ค. 4ms๊ฐ€ ๊ฑธ๋ฆฐ ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค. #include using namespace std; int main() { int n, x, i = 0; cin >> n >> x; int a[n]; int answer[n]; for (i = 0; i > a[i]; } for (i = 0; i < n; i++) { if (a[i] < x) cout