AtCoder Beginner Contest 257 下分记录
A 题:
暴力拼串然后输出就行了。
string s; signed main() { int n = read(), k = read(); for(int i = 1; i <= 26; i++) { for(int j = 1; j <= n; j++) { s += i + 'A' - 1; } } cout << s[k - 1]; return 0; }
B题:
比着题目模拟就行了。
int n, k, Q; int a[N]; signed main() { n = read(), k = read(), Q = read(); for(int i = 1; i <= k; i++) a[i] = read(); for(int i = 1; i <= Q; i++) { int x = read(); if(a[x] == n) continue; if(a[x + 1] != a[x] + 1) a[x] = a[x] + 1; } for(int i = 1; i <= k; i++) cout << a[i] << " "; return 0; }
C 题:
我们设 表示从 的 个数。
然后做法就很显然了, 排序后就可以用前缀和来搞了。
时间复杂度 。
int qzh[N][2], ans; struct Node { int w, male; bool operator < (const Node &x) const { return w < x.w; } }a[N]; signed main() { int n = read(); for(int i = 1; i <= n; i++) scanf("%1lld", &a[i].male); for(int i = 1; i <= n; i++) scanf("%lld", &a[i].w); sort(a + 1, a + n + 1); for(int i = 1; i <= n; i++) { if(a[i].male == 1) qzh[i][1] = qzh[i - 1][1] + 1, qzh[i][0] = qzh[i - 1][0]; else qzh[i][1] = qzh[i - 1][1], qzh[i][0] = qzh[i - 1][0] + 1; } for(int i = 0; i <= n; i++) { if(a[i].w == a[i + 1].w) continue; ans = max(ans, qzh[i][0] + qzh[n][1] - qzh[i][1]); } cout << ans; return 0; }
本文作者:TLE_Automation
本文链接:https://www.cnblogs.com/tttttttle/p/16412522.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!