当前位置:网站首页>On the usage of a magic function
On the usage of a magic function
2022-07-01 20:05:00 【Aidan 347】
Title Description
Given a length of n Sequence a_i, Definition a[i] For the first time i The value of two elements . Now we need to find the most valuable in the sequence “ The paragraph ”. A paragraph is defined as having a length of [S,T] A continuous sequence between . The most valuable paragraph refers to the paragraph with the highest average value ,
Average of paragraphs = Total paragraph value / Paragraph length .
I / O format
Input format :
The first line is an integer n, Represents sequence length .
The second line is two integers S and T, Indicates the range of paragraph length , stay [S,T] Between .
Third line to third line n+2 That's ok , An integer in each line represents the value index of each element .
Output format :
A real number , Retain 3 Decimal place , Represents the average value of the best paragraph .
I/o sample
sample input #1:
3
2 2
3
-1
2
sample output #1:
1.000
explain
【 Data range 】
about 30% Data are available. n<=1000.
about 100% Data are available. n<=100000,1<=S<=T<=n,-10000<= Value index <=10000.
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int n,s,t;
int a[N];
double res;
int main()
{
scanf("%d", &n);
scanf("%d%d", &s, &t);
for(int i=1;i<=n;i++) scanf("%d", &a[i]);
for(int i=1;i<=n;i++) a[i]+=a[i-1];
for(int i=s;i<=t&&(double)clock() / CLOCKS_PER_SEC <= 0.95;i++)
{
for(int j=1;j+i-1<=n;j++)
{
int r = j+i-1;
double sum = a[r] - a[j-1];
res = max(res, (double)(sum*1.0/i));
}
}
printf("%.3lf",res);
return 0;
}The following code can ensure the cycle 0.95s after Automatically exit the loop ...
(double)clock() / CLOCKS_PER_SEC <= 0.95
边栏推荐
- 由浅入深学会白盒测试用例设计
- 有意思了!数据库也搞Serverless!
- Hls4ml/vivado HLS error reporting solution
- P2433 [deep foundation 1-2] primary school mathematics n in one
- On the next generation entrance of the metauniverse -- the implementation of brain computer interface
- 【蓝桥杯Web】2022年第十三届蓝桥杯Web大学组国赛真题解析
- RichView RichEdit SRichViewEdit PageSize 页面设置与同步
-
- Simple but modern server dashboard dashdot
- List is divided into sets that meet and do not meet conditions (partitioningby)
猜你喜欢
![[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached](/img/c8/a205ddc2835c87efa38808cf31f59e.jpg)
[research materials] iResearch tide Watching: seven major trends in the clothing industry - Download attached

3D全景模型展示可视化技术演示

Flask 常用组件

What if the win11 shortcut key switching input method doesn't respond? Shortcut key switching input method does not respond
![[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached](/img/50/926cc5bce83f8b195b3e2072b656bf.jpg)
[research data] observation on the differences of health preservation concepts among people in 2022 - Download attached

Modsim basic use (Modbus simulator)

振弦采集模块测量振弦传感器的流程步骤

Realize pyramids through JS (asterisk pyramid, palindrome symmetric digital pyramid)

A quietly rising domestic software, low-key and powerful!

优质笔记软件综合评测和详细盘点(一) Notion、Obsidian、RemNote、FlowUs
随机推荐
大厂做狼,小厂做狗?
Keras machine translation practice
Arduino Stepper库驱动28BYJ-48步进电机测试程序
渗透工具-TrustedSec 公司的渗透测试框架 (PTF)
Write blog documents
PowerDesigner design name and comment replacement
Getting started with fastdfs
全国职业院校技能大赛网络安全“splunk“详细配置
振弦采集模块测量振弦传感器的流程步骤
1592 example 1 King (sgu223 loj10170 luogu1896 increase + / provincial election -) violent thinking pressure DP 01 Backpack
SQL getting started plan-1-select
Detailed configuration of network security "Splunk" in national vocational college skills competition
Procédure de mesure du capteur d'accord vibrant par le module d'acquisition d'accord vibrant
Myslq ten kinds of locks, an article will take you to fully analyze
Install redis under Linux and configure the environment
list大集合等比分割成多个小list集合
【let var const】
ORA-01950
uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理