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的更多相关文章

  1. Codeforces 1009C: Annoying Present

    C. Annoying Present time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  2. C. Annoying Present SB题

    C. Annoying Present time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Educational Codeforces Round 47 (Rated for Div. 2) :C. Annoying Present(等差求和)

    题目链接:http://codeforces.com/contest/1009/problem/C 解题心得: 题意就是一个初始全为0长度为n的数列,m此操作,每次给你两个数x.d,你需要在数列中选一 ...

  4. 【Codeforces 1009C】Annoying Present

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 其实就是让你最后这n个数字的和最大. 加上的x没有关系.因为肯定都是加上n个x 所以直接加上就可以了 主要在于如何选取j 显然我们要找到一个位 ...

  5. Codeforces ~ 1009C ~ Annoying Present (贪心)

    题意 一个长度为n的数组(初始全为0),进行m次操作. 操作:给你x,d,你任意挑选一个 i (1~n),每个数字加上 x+|i-j|*d( j 表示对应数字的下标) 问m次操作后的最大算术平均值为多 ...

  6. Educational Codeforces Round 47 (Rated for Div. 2) 题解

    题目链接:http://codeforces.com/contest/1009 A. Game Shopping 题目: 题意:有n件物品,你又m个钱包,每件物品的价格为ai,每个钱包里的前为bi.你 ...

  7. Educational Codeforces Round 47 (Div 2) (A~G)

    目录 Codeforces 1009 A.Game Shopping B.Minimum Ternary String C.Annoying Present D.Relatively Prime Gr ...

  8. Educational Codeforces Round 47

    A. Game Shopping 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, m, c[N ...

  9. cordforce Educational Codeforces Round 47 补题笔记 <未完>

    题目链接 http://codeforces.com/contest/1009 A. Game Shopping 直接模拟即可,用了一个队列来存储账单 #include <iostream> ...

随机推荐

  1. 各种 Java Thread State 分析

    转自:https://www.cnblogs.com/zhengyun_ustc/archive/2013/03/18/tda.html 1,线程状态为“waiting for monitor ent ...

  2. IdentityServer4学习笔记汇总(实现传送门在底部)

    前言 互联网时代,对信息和资源的保护越发苛刻,在所有应用中授权和认证是必不可少缺少的一部分.如果一个应用没有授权和认证那么这个应用就是不完整或者说不安全的应用.在.Net平台给我们提供了一套完整的授权 ...

  3. [windows官网]虚拟地址空间

    虚拟地址空间 https://docs.microsoft.com/zh-cn/windows-hardware/drivers/gettingstarted/virtual-address-spac ...

  4. 【51nod】1602 矩阵方程的解

    [51nod]1602 矩阵方程的解 这个行向量显然就是莫比乌斯函数啦,好蠢的隐藏方法= = 然后我们尝试二分,二分的话要求一个这个东西 \(H(n) = \sum_{i = 1}^{n} \mu(i ...

  5. 数据库相关概念讲解(java)

    1.常用类或接口介绍 1.DataSource接口 通过javaAPI中javax.sql.DataSource接口注释了解. 1.DataSource功能 如下图: 翻译: DataSource对象 ...

  6. Excel关联匹配函数

    1.=VLOOKUP (lookup_value, table_array, col_index_num, [range_lookup]) ​ lookup_value 相当于python中的键,用来 ...

  7. 制作一个centos+jdk8+tomcatd9镜像

    docker解析:     1.登录docker             docker ecex –it 容器名/容器id /bin/bash         例如:             dock ...

  8. 【动态规划】Concerts

    Concerts 题目描述 John enjoys listening to several bands, which we shall denote using A through Z. He wa ...

  9. JS 07 Dom

    DOM(Document Object Model): 结点的概念:整个文档就是由层次不同的多个节点组成,可以说结点代表了全部内容. 结点类型 1.元素结点 2.属性结点 3.文本结点   结点的注意 ...

  10. 官网下载CentOS教程(各版本)

    1.进入官网,并点击下图所示的红框(alternative downloads) 官网网址:https://www.centos.org/download/  2.在往下翻,可以看到如下图的历史版本, ...