CF427B
2021/5/16 10:55:33
本文主要是介绍CF427B,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
没人用ST表么?他比线段树快。
考虑先把ST表跑下来,然后循环一遍区间的起点,看一下这个区间的最大值,和 \(t\) 比较一下即可。
然后这题就做完了。ST表裸题。
int f[2000010][21], Logn[2000010], n, t, c; void preLog() { Logn[1] = 0; Logn[2] = 1; rep(i, 3, 2000000) Logn[i] = Logn[i / 2] + 1; } void preF() { rep(j, 1, 21) for(int i = 1; i + (1 << j) - 1 <= n; i++) f[i][j] = max(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]); } int main() { int ans = 0; read(n), read(t), read(c); rep(i, 1, n) read(f[i][0]); preLog(); preF(); rep(i, 1, n - c + 1) { int x = i, y = i + c - 1; int s = Logn[y - x + 1]; if((max(f[x][s], f[y - (1 << s) + 1][s])) <= t) ++ans; } print(ans); return 0; }
这篇关于CF427B的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-25Elevate Your Lead Generation Game with Maps Scraper AI
- 2024-05-15PingCAP 黄东旭参与 CCF 秀湖会议,共探开源教育未来
- 2024-05-13PingCAP 戴涛:构建面向未来的金融核心系统
- 2024-05-09flutter3.x_macos桌面os实战
- 2024-05-09Rust中的并发性:Sync 和 Send Traits
- 2024-05-08使用Ollama和OpenWebUI在CPU上玩转Meta Llama3-8B
- 2024-05-08完工标准(DoD)与验收条件(AC)究竟有什么不同?
- 2024-05-084万 star 的 NocoDB 在 sealos 上一键起,轻松把数据库编程智能表格
- 2024-05-08Mac 版Stable Diffusion WebUI的安装
- 2024-05-08解锁CodeGeeX智能问答中3项独有的隐藏技能