80分求助

P1823 [COI2007] Patrik 音乐会的等待

```cpp #include <bits/stdc++.h> using namespace std; stack<int> st; int x,n,ans,sizen; inline int read(){ int x=0,f=1; char ch=getchar(); while (ch<'0'||ch>'9'){ if (ch=='-') f=-1; ch=getchar(); } while (ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } inline void write (int x) { if (x < 0) { putchar ('-'); x = -x; } if (x > 9) write (x / 10); putchar (x % 10 + '0'); } int main(){ n=read(); while(n--){ x=read(); int t=1; while (sizen && x>=st.top()){ if (st.top()==x) t++; ans++; st.pop(); sizen--; } if (sizen){ ans++; } while (t--){ st.push(x); sizen++; } } write(ans); return 0; } ``` 现在加入了快写,仍然是3个 $TLE$ ,希望大家的帮助。
by CSP_Alex_juruo @ 2024-04-01 19:16:47


哇,是你
by __wjy__ @ 2024-04-03 19:59:52


不是这一看就会TLE啊
by __wjy__ @ 2024-04-03 20:00:32


~~话说你这代码好像题解的~~
by __wjy__ @ 2024-04-03 20:05:08


@[CSP_Alex_juruo](/user/669764)
by __wjy__ @ 2024-04-03 20:05:25


@[__wjy__](/user/735264) 你怎么看出来的
by CSP_Alex_juruo @ 2024-04-04 09:38:14


@[CSP_Alex_juruo](/user/669764) 用手搓栈
by 18955329590hhc @ 2024-04-26 19:28:40


|