CF1003C Intense Heat 题解
Content
给定一个长度为 \(n\) 的数列,求数列中所有长度 \(\geqslant k\) 的区间的最大平均值。
数据范围:\(1\leqslant k,n,a_i\leqslant 5000\)。
Solution
我们通过预处理前缀和之后,再直接暴力枚举所有长度 \(\geqslant k\) 的区间的平均值,取其最大值即可。
Code
int k, n, a[5007], s[5007];
double ans;
int main() {
//This program is written in Windows 10 by Eason_AC
getint(n), getint(k);
_for(i, 1, n) {getint(a[i]); s[i] = s[i - 1] + a[i];}
_for(j, k, n)
_for(i, 1, n - j + 1)
ans = max(ans, (s[i + j - 1] - s[i - 1]) * 1.0 / j);
printf("%.12lf", ans);
return 0;
}
CF1003C Intense Heat 题解的更多相关文章
- Intense Heat(前缀和或尺取)
The heat during the last few days has been really intense. Scientists from all over the Berland stud ...
- 『ACM C++』 Codeforces | 1003C - Intense Heat
今日兴趣新闻: NASA 研制最强推进器,加速度可达每秒 40 公里,飞火星全靠它 链接:https://mbd.baidu.com/newspage/data/landingsuper?contex ...
- CF 1003C Intense Heat【前缀和/精度/双层暴力枚举】
The heat during the last few days has been really intense. Scientists from all over the Berland stud ...
- 7.24-Codeforces Round #494 (Div. 3)
链接:http://codeforces.com/contest/1003 A. Polycarp's Pockets 题型:模拟 题意:把初始集合拆分,要求相同的数不在同一个集合中,求出需要的集合个 ...
- 马婕 2014MBA专硕考试 报刊选读 4 朝鲜战争会爆发吗?(转)
http://blog.sina.com.cn/s/blog_3e66af4601016ela.html War unlikely, but Koreans still on cliff edge 战 ...
- Codeforces Round #494 (Div 3) (A~E)
目录 Codeforces 1003 A.Polycarp's Pockets B.Binary String Constructing C.Intense Heat D.Coins and Quer ...
- 洛谷P1339 [USACO09OCT]热浪Heat Wave 题解
题目传送门 这道题实际非常简单好奇是怎么变黄的... 其实也就是一个SPFA,本人非常懒,不想打邻接表,直接用矩阵就好啦... #include<bits/stdc++.h> using ...
- 题解 P1339 【[USACO09OCT]热浪Heat Wave】
题目链接 这道题纯属是一个裸的SPFA: 建议先把模板AC之后再做. 只需要做一些手脚,就是在加边的时候加一个双向边就好. 然后再第一次加点的时候 看不懂模板的出门左转度娘. 推荐下面一片讲解: 友链 ...
- 3408: [Usaco2009 Oct]Heat Wave 热浪
3408: [Usaco2009 Oct]Heat Wave 热浪 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 67 Solved: 55[Subm ...
随机推荐
- [源码解析] PyTorch 分布式(11) ----- DistributedDataParallel 之 构建Reducer
[源码解析] PyTorch 分布式(11) ----- DistributedDataParallel 之 构建Reducer 目录 [源码解析] PyTorch 分布式(11) ----- Dis ...
- NLP获取词向量的方法(Glove、n-gram、word2vec、fastText、ELMo 对比分析)
自然语言处理的第一步就是获取词向量,获取词向量的方法总体可以分为两种两种,一个是基于统计方法的,一种是基于语言模型的. 1 Glove - 基于统计方法 Glove是一个典型的基于统计的获取词向量的方 ...
- Codeforces 1406E - Deleting Numbers(根分+数论)
Codeforces 题面传送门 & 洛谷题面传送门 一道个人感觉挺有意思的交互题,本人一开始想了个奇奇怪怪的做法,还以为卡不进去,结果发现竟然过了,而且还是正解( 首先看到这类题目可以考虑每 ...
- 快速傅里叶变换(FFT)随笔
终于学会了FFT,水一篇随笔记录一下 前置知识网上一大堆,这里就不多赘述了,直接切入正题 01 介绍FFT 这里仅指出FFT在竞赛中的一般应用,即优化多项式乘法 一般情况下,计算两个规模为$n$的多项 ...
- C语言计算fastq文件GC含量
C语言小练习:计算非压缩fastq格式的GC含量 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <strin ...
- cpu的性能测试
#!/bin/bash #user%加上sys%是性能的评判标准 User_sys_a=`sar -u 1 3 |tail -1 |awk '{print $3"+"$5}'|bc ...
- 一个简单但能考察C语言基础的题目
请看题: #include<stdio.h> int a=1; int main(void) { int a=a; printf("a=d%\n",a); return ...
- Spark基础:(一)初识Spark
1.Spark中的Python和Scala的Shell (1): Python的Spark Shell 也就是我们常说的PySpark Shell进入我们的Spark目录中然后输入 bin/pyspa ...
- 【STM8】SPI通讯
这篇内容有点长,如果有人想透过我的博客学习STM8的SPI,那是我的荣幸 首先我要先说大纲,这样大家心里比较有底,可以把精力都用在SPI理解上 [SPI初步介绍]:介绍SPI如何接线.名称解释.通讯注 ...
- Kotlin 学习(1)
本文出自链接:https://www.jianshu.com/p/ef9584a8ebf8 Kotlin的插件安装: Settings->Plugins->Browse Repositor ...