Annoying Present
http://codeforces.com/group/1EzrFFyOc0/contest/1009/problem/C
题意:原本有一个n个0的数组a[],你对它进行m次操作,每次操作让a[j]+=x+d*(dish(i,j))(dish(i,j)代表abs(i-j))。其中i是任意的。让你求经过这m次操作所能得到数组的平均值最大为多少。其实这里有一点贪心的思想,就是我们要尽量的让a[j]最大,那么和x是没有关系的,初始时数组和为ans=0;那么以后每次操作ans肯定会+=n*x;重点是对d的讨论,d<0是我们要让距离和最小,d>=0让距离和最大,这样就达到了我们的步步最优的条件。接下来就很简单了,直接讨论距离和即可
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
#define se second
#define fi first
const int INF= 0x3f3f3f3f;
const int N=1e5+; ll n,m,x,d; int main()
{
cin>>n>>m;
ll ans=;
while(m--)
{
cin>>x>>d;
if(d<){
if(n&)
ans+=(n*n-)/*d+n*x;
else
ans+=n*n/*d+n*x;
}
else if(d>=){
ans+=n*(n-)/*d+n*x;
}
}
double res=ans*1.0/n;
printf("%.15lf",res);
}
Annoying Present的更多相关文章
- Codeforces 1009C: Annoying Present
C. Annoying Present time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- C. Annoying Present SB题
C. Annoying Present time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Educational Codeforces Round 47 (Rated for Div. 2) :C. Annoying Present(等差求和)
题目链接:http://codeforces.com/contest/1009/problem/C 解题心得: 题意就是一个初始全为0长度为n的数列,m此操作,每次给你两个数x.d,你需要在数列中选一 ...
- 【Codeforces 1009C】Annoying Present
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 其实就是让你最后这n个数字的和最大. 加上的x没有关系.因为肯定都是加上n个x 所以直接加上就可以了 主要在于如何选取j 显然我们要找到一个位 ...
- Codeforces ~ 1009C ~ Annoying Present (贪心)
题意 一个长度为n的数组(初始全为0),进行m次操作. 操作:给你x,d,你任意挑选一个 i (1~n),每个数字加上 x+|i-j|*d( j 表示对应数字的下标) 问m次操作后的最大算术平均值为多 ...
- Educational Codeforces Round 47 (Rated for Div. 2) 题解
题目链接:http://codeforces.com/contest/1009 A. Game Shopping 题目: 题意:有n件物品,你又m个钱包,每件物品的价格为ai,每个钱包里的前为bi.你 ...
- Educational Codeforces Round 47 (Div 2) (A~G)
目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Gr ...
- Educational Codeforces Round 47
A. Game Shopping 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, m, c[N ...
- cordforce Educational Codeforces Round 47 补题笔记 <未完>
题目链接 http://codeforces.com/contest/1009 A. Game Shopping 直接模拟即可,用了一个队列来存储账单 #include <iostream> ...
随机推荐
- url请求特殊字符转换
一.问题阐述 用URL传参数的时候,用&符号连接,如果某一个参数中含"#$ ^ & * + ="这些符号的时候,在另一个页面getParameter就会取不到传过来 ...
- c#,回文数判断
回文数:将数值反过来.如:123 反过来是321 ,如果两个数相等,则是回文,否则不是 using System; namespace ConsoleApp1 { class Program { st ...
- Word 查找替换高级玩法系列之 -- 把论文中的缩写词快速变成目录下边的注释表
1. 前言 问题:Word写论文如何把文中的缩写快速转换成注释表? 原来样子: 想要的样子: 2. 步骤 使用查找替换高级用法,替换缩写顺序 选中所有文字 打开查找替换对话框,输入以下表达式: 替换后 ...
- Counting Cliques(HDU-5952)【DFS】
题目链接:https://vjudge.net/problem/HDU-5952 题意:有一张无向图,求结点数量为S的团的数量. 思路:如果不加一点处理直接用DFS必然会超时,因为在搜索过程中会出现遍 ...
- jenkins sonarqube 代码检测部署
install pgsql and sonarqube docker run --name postgresqldb -e POSTGRES_USER=sonar -e POSTGRES_PASSWO ...
- 100天搞定机器学习|Day3多元线性回归
前情回顾 [第二天100天搞定机器学习|Day2简单线性回归分析][1],我们学习了简单线性回归分析,这个模型非常简单,很容易理解.实现方式是sklearn中的LinearRegression,我们也 ...
- nginx设置导航&安装showdoc&创建文件服务&zabbix&grafana
安装环境: [root@nginx showdoc]# cat /etc/centos-release #系统版本 CentOS Linux release 7.5.1804 (Core) [root ...
- S03_CH11_基于TCP的QSPI Flash bin文件网络烧写
S03_CH11_基于TCP的QSPI Flash bin文件网络烧写 11.1概述 针对ZYNQ中使用QSPI BOOT的应用,将BOOT.bin文件烧写至QSPI Flash基本都是通过USB C ...
- 【C#】上机实验一
1.开发一个控制台应用程序,根据提示从键盘获取一个华氏温度,请转换并输出对应的摄氏温度. using System; namespace Project { class Program { publi ...
- 普通表分区改造_rename方式
一.需求 配合开发人员,对业务临时表进行分区改造(业务认为的临时表,只需要保留近一月数据,并非oracle临时表类型) 二.如下记录完整过程 开发需求 TS_PM 以time_key分区 .沟通明确方 ...