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. MYSQL查找总结

      a.条件判断where select * from 表 where id > 1 and name != 'alex' and num = 12; select * from 表 where ...

  2. VSCode Web Developement for Javascript. Must have plugins.

    Es6 Javascript front-end web developemnt must have plugins Prettier - Code Formatter Javascript (ES6 ...

  3. js获取屏幕高度宽度

    获取各种屏幕的宽度和高度Javascript: 网页可见区域宽: document.body.clientWidth网页可见区域高: document.body.clientHeight网页可见区域宽 ...

  4. F题 hdu 1431 素数回文

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1431 素数回文 Time Limit: 2000/1000 MS (Java/Others)    M ...

  5. c语言中的size_t

    size_t unsigned int 类型,无符号,它的取值没有负数.用来表示 参数/数组元素个数,sizeof 返回值,或 str相关函数返回的 size 或 长度.sizeof 操作符的结果类型 ...

  6. python开发第二十六天CMDB

    概要: 1.采集资产 2.API 一.资产采集 1.采集方式的配置 2.插件的定制 3.测试模式 4.错误日志(必须是行级的详细错误信息) 5.汇报数据-->遵循资产的唯一性 (1)只针对物理机 ...

  7. Linux中查看进程占用内存的情况【转】

    转自:http://hutaow.com/blog/2014/08/28/display-process-memory-in-linux/ Linux中查看某个进程占用内存的情况,执行如下命令即可,将 ...

  8. 简单的自动化运维工具(shell+except+whiptail+功能模块化函数+循环)

    简单的自动化运维工具(shell+except+whiptail+功能模块化函数+循环) http://www.cnblogs.com/M18-BlankBox/p/5881700.html

  9. HDU 6112 今夕何夕 蔡勒公式

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6112题意:中文题目 分析:关键点在与如何计算一个日期是星期几,这个可以通过蔡勒公式来计算.基姆拉尔森计 ...

  10. Centos7 环境准备

    Centos7 环境准备 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld #关闭selinux sed -i 's/SELINU ...