Codeforces Round 856 (Div. 2)C
C. Scoring Subsequences
思路:我们想要找到满足的最大值的长度最长的的区间,因为单调不减,所以更大的数一定在最大值的里面包含,所以我们用两个指针维护这样一个满足当前i的最大值区间,当新来一个数,这时我们答案里面一定要包含这个数,我们看能否保持这个长度,能不能保持需要看j指针所指的数/区间长度和1的大小比较,如果大于1乘上去一定可以使结果增大,反之会使结果减小,那么这个数就不能要了。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int a[N];
int ans = 0;
void run()
{
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++ i) scanf("%d", &a[i]);
for(int i = 1, j = 1; i <= n; ++ i)
{
while(j <= i && a[j] / (i - j + 1) < 1) ++ j;
cout << i - j + 1 << ' ';
}
cout << endl;
}
int main()
{
// freopen("1.in", "r", stdin);
int t;cin >> t;
while(t --) run();
return 0;
}
Codeforces Round 856 (Div. 2)C的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- 【Qt 应用】模仿实现Win10的Wifi列表
这里使用 Qt 模仿实现了 Win10 系统下的 Wifi 列表,主要用的是 QlistWidget + xml + cmd命令行 实现. 效果 下载地址 https://github.com/con ...
- Java使用qq邮箱发送邮件(可做验证码使用)
pom.xml中导入发邮件需要的jar包 <!-- 邮箱 --> <dependency> <groupId>javax.mail</groupId> ...
- 2023-07-12:RocketMQ如何做到消息不丢失?
2023-07-12:RocketMQ如何做到消息不丢失? 答案2023-07-12: RocketMQ通过刷盘机制.消息拉取机制和ACK机制等多种方式来确保消息投递的可靠性,防止消息丢失. 1.刷盘 ...
- ZEGO即构科技荣获36氪【WISE2020中国新经济之王最具影响力企业】
12月8-10日,36氪重磅新经济峰会WISE2020新经济之王大会将在北京举办.近日,2020新经济之王--中国最具影响力企业榜单陆续发布,全球云通讯服务商即构科技,凭借在企业服务领域硬核出色的技术 ...
- Java 中怎样将 bytes 转换为 long 类型?
将bytes 转换为long类型: 第一种方式: String 接收 bytes 的构造器转成 String,再 Long.parseLong: 但此种情况需要注意:字节数组中的每个字节都必须是有效的 ...
- Mybatis(配置解析解读(核心))
核心配置文件 mybaits-confing.xml *properties(属性) *settring(设置) *typeAliases(类型别名) *typeHandlers(类型处理器) *ob ...
- Linux chroot的关联操作 mount --bind
假设新的根文件系统已经挂载到 /mnt mount --bind /dev /mnt/dev/ mount --bind /sys /mnt/sys/ mount --bind /proc /mnt/ ...
- 看,这些 plugins 常用又简单
前面文章中 体验了webpack的打包 .解析css资源 .处理图片字体等文件 接下来看看 plugins 有什么作用吧~ 项目路径如下,和上一篇 处理图片字体等文件 项目保持一致 demo ├─ s ...
- Jenkins用户管理(二):不同用户分配不同的任务访问权限
需求:不同用户访问到不同的Jenkins任务. 依赖插件:Role-based Authorization Strategy 1. 插件安装 进入[系统管理]-[插件管理]-[可用插件],搜索Role ...
- 一文详解自然语言处理两大任务与代码实战:NLU与NLG
自然语言处理(NLP)涵盖了从基础理论到实际应用的广泛领域,本文深入探讨了NLP的关键概念,包括词向量.文本预处理.自然语言理解与生成.统计与规则驱动方法等,为读者提供了全面而深入的视角. 作者 Te ...