B. Regular Bracket Sequence
1.E. Arranging The Sheep2.C. Team3.C. RationalLee4.B. Preparing Olympiad5.B. Find The Array6.E. Accidental Victory7.A. Learning Languages8.A. k-th divisor9.B. Quasi Binary10.蓝桥杯-地宫取宝11.D. Divide by three, multiply by two12.D. Game With Array13.B. Composite Coloring14.洛谷 P1204 [USACO1.2] 挤牛奶Milking Cows15.洛谷 P3353 在你窗外闪耀的星星16.洛谷 P8818 [CSP-S 2022] 策略游戏17.Educational Codeforces Round 164 (Rated for Div. 2)18.E. Chain Reaction19.Manthan, Codefest 18 (rated, Div. 1 + Div. 2) D. Valid BFS?20.D. Distance in Tree21.D. Multiplication Table22.C. Mixing Water23.B. Greg and Graph24.D. Another Problem About Dividing Numbers25.Acwing 143. 最大异或对26.Acwing 3485. 最大异或和27.C. Checkposts28.E. Lomsat gelral29.D. Powerful array30.D. Deleting Divisors31.Codeforces Round 950 (Div. 3)32.Codeforces Round 951 (Div. 2)33.SuntoryProgrammingContest2024(AtCoder Beginner Contest 357)34.Codeforces Round 952 (Div. 4)35.AtCoder Beginner Contest 35836.B. Modulo Sum37.D. Soldier and Number Game38.AtCoder Beginner Contest 35939.Codeforces Round 954 (Div. 3)40.Codeforces Round 955 (Div. 2, with prizes from NEAR!)41.AtCoder Regular Contest 18042.D - Ghost Ants43.AtCoder Beginner Contest 361)44.Codeforces Round 957 (Div. 3)45.E. Decode46.Educational Codeforces Round 168 (Rated for Div. 2)47.B. Parity and Sum48.P1972 [SDOI2009] HH的项链49.Codeforces Round 966 (Div. 3) VP50.https://codeforces.com/contest/2004/problem/B51.C. Splitting Items52.D. Colored Portals53.Codeforces Round 967 (Div. 2)54.D. Determine Winning Islands in Race55.C. Turtle and Good Pairs56.Codeforces Round 970 (Div. 3)(VP)57.G. Sakurako's Task58.Codeforces Round 971 (Div. 4)59.C. Lazy Narek
60.B. Regular Bracket Sequence
61.C. News Distribution62.B. Karen and Coffee63.G. 2^Sort64.C. Johnny and Another Rating Drop65.A. Greg and Array66.D2. Magic Powder - 267.C. Schedule Management68.C. Constanze's Machine69.C. Soldier and Cards70.C. Berland Regional71.E. Anna and the Valentine's Day Gift72.B. Polo the Penguin and Matrix73.B. Fortune Telling74.C. Powers Of Two75.D. Palindromes Coloring76.C. Phoenix and Towershttps://codeforces.com/contest/26/problem/B
给定一个包含括号的字符串,问最少移除多少字符可以让字符串合法
两个点,第一是如果当前)超标了,那这个必须删除。第二是遍历完所有字符后,如果(是多的,要算到总数里面。
inline void solve(){
string s;
cin >> s;
int cnt = 0;
int ans = 0;
for (const auto& x : s) {
cnt += (x == '(' ? 1 : -1);
if (cnt < 0) {
cnt = 0;
ans ++;
}
}
ans += cnt;
cout << s.size() - ans << '\n';
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】