A.

题意:就是有一个大桌子,环绕有顺势站1~m共m个座位,n个选手坐在部分位置上。然后如果有一个人a了一道题,却没有立刻发气球给他,他产生怒气值是发气球给他的时间减去a题时间。现在有一个机器人顺时针环绕桌子发球,每个单位时间走过一个位置。问机器人在哪个位置开始发气球总怒气值最小,输出最小怒气值。


其实是个傻逼思维题。假如他从位置m开始发气球,对于每个位置i,他到达的时间为k*m+i,所以对于每个它在时刻t a的题,他需要等待t-(k*m+i)中最小的正整数时间。随便算算就能知道每一题从m位置开始具体产生的怒气值,从而算出怒气总值作为初始值(当然从其他位置也行)。然后他往逆时针移动一个位置开始,相当于所有a题时间在%m的意义下+1。因此我们从小到大排个序,从最后一个数字往第一个数字遍历一遍,每次的操作都是把该为数字加到0的数加到所有题上,算算总的怒气值,在这里面一定产生一个最小的怒气值。

 #include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define clr_1(x) memset(x,-1,sizeof(x))
#define mod 1000000007
#define LL long long
using namespace std;
const int N=;
int n,m,q,k,T,u,v;
int pos[N],info[N];
LL pp,qq,tt,ans,all;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d%d",&n,&m,&q);
for(int i=;i<=n;i++)
{
scanf("%d",&pos[i]);
if(pos[i]==m)
pos[i]=;
}
all=;
for(int i=;i<=q;i++)
{
scanf("%d%d",&u,&v);
v=v%m;
info[i]=(pos[u]-v+m)%m;
all+=info[i];
}
n=q;
sort(info+,info+n+);
LL qq=;
ans=all;
for(int i=n;i>=;i--)
{
pp=m-(info[i]+qq);
all-=(LL)info[i]+qq;
all+=pp*(n-);
qq+=pp;
if(all<ans)
ans=all;
}
printf("%lld\n",ans);
}
return ;
}

ccpc秦皇岛部分题解的更多相关文章

  1. 2017 CCPC秦皇岛 E题 String of CCPC

    BaoBao has just found a string  of length  consisting of 'C' and 'P' in his pocket. As a big fan of ...

  2. 2017 CCPC秦皇岛 A题 A Ballon Robot

    The 2017 China Collegiate Programming Contest Qinhuangdao Site is coming! There will be  teams parti ...

  3. 2017 CCPC 哈尔滨站 题解

    题目链接  2017 CCPC Harbin Problem A Problem B Problem D Problem F Problem L 考虑二分答案. 设当前待验证的答案为x 我们可以把第二 ...

  4. 2017 CCPC秦皇岛 M题 Safest Buildings

    PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parach ...

  5. 2017 CCPC秦皇岛 L题 One Dimensions Dave

    BaoBao is trapped in a one-dimensional maze consisting of  grids arranged in a row! The grids are nu ...

  6. 2017 CCPC秦皇岛 H题 Prime set

    Given an array of  integers , we say a set  is a prime set of the given array, if  and  is prime. Ba ...

  7. 2017 CCPC秦皇岛 G题 Numbers

    DreamGrid has a nonnegative integer . He would like to divide  into nonnegative integers  and minimi ...

  8. 2018 CCPC秦皇岛 C题 Crusader Quest

    Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the ...

  9. 2018年9月28日CCPC秦皇岛站参赛总结

    day1: 被中间结果超出int范围给叉了,立刻意识到了自己的弱小以及校赛出题的时候是怎么叉别人的 day2: 签到签了40分钟,谨慎一些还是很好的,机子重启耽误了一些时间 一道暴力+LCS的简单题被 ...

随机推荐

  1. js_实现给未来元素添加事件。

    未来元素:不是一个页面上的元素,是通过js或者通过后台直接渲染在页面上的元素,也就是说这些元素不是直接写在document中的. 1.对于未来元素,我们想直接用js或者jq操作它们是不起作用的. $( ...

  2. MapperScannerConfigurer不 property-placeholder

    关于org.mybatis.spring.mapper.MapperScannerConfigurer不支持 property-placeholder 参考了http://www.oschina.ne ...

  3. 7.0docker镜像和仓库

    repository:镜像的仓库 registry :docker组件的仓库,docker镜像的存储服务 tag :镜像的标签 例:ubuntu:14.04  ubuntu:latest 删除镜像 d ...

  4. 基于ansj_seg和nlp-lang的简单nlp工具类

    1.首先在pom中引入ansj_seg和nlp-lang的依赖包, ansj_seg包的作用: 这是一个基于n-Gram+CRF+HMM的中文分词的java实现: 分词速度达到每秒钟大约200万字左右 ...

  5. GDB实战

    程序中除了一目了然的Bug之外都需要一定的调试手段来分析到底错在哪.到目前为止我们的调试手段只有一种:根据程序执行时的出错现象假设错误原因,然后在代码中适当的位置插入 printf ,执行程序并分析打 ...

  6. 64_k1

    KoboDeluxe-0.5.1-22.fc26.x86_64.rpm 13-Feb-2017 22:11 1626454 k3b-17.04.1-1.fc26.x86_64.rpm 25-May-2 ...

  7. mapper.xml中的<sql>标签

    原文链接:http://blog.csdn.net/a281246240/article/details/53445547 sql片段标签<sql>:通过该标签可定义能复用的sql语句片段 ...

  8. ubuntu命令行操作mysql常用操作

    登陆mysql harvey@harvey-Virtual-Machine:~/ruby/mydiary$ mysql -u root -p Enter password: Welcome to th ...

  9. jequry_rotate.js用来写旋转类的东西的插件(如:抽奖转盘)

    网上发现一个很有意思的jQuery旋转插件,支持Internet Explorer 6.0+ .Firefox 2.0 .Safari 3 .Opera 9 .Google Chrome,高级浏览器下 ...

  10. elasticsearch批量删除(查询删除)

    注:delete by query只适用于低于elasticsearch2.0的版本(不包含2.0).有两种形式: 1.无请求体 curl -XDELETE 'localhost:9200/twitt ...