100197G Robbers
题目大意
看式子懂题意系列...
分析
自然想到我们先按比例下取整得到一个值,再按每个人这样分配所产生的值从大到小排序,然后将剩下的几个金币自大到小每人分配一个,代码挺好理解的,详见代码。
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define li long long
#define pb push_back
#define mp make_pair
#define y1 y12345678909
#define rii register int
#define pii pair<int,int>
#define r(x) scanf("%d",&x)
#define ck(x) cout<<x<<endl;
#define uli unsigned long long
#define sp cout<<"---------------------------------------------------"<<endl
struct node {
int d,no;
}a[];
int ans[];
inline bool cmp (const node x,const node y){
return x.d<y.d;
}
int main(){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
int n,m,i,z,y,all,x;
r(n),r(m),r(y);
all=m;
for(i=;i<=n;i++){
r(x);
z=x*m;
ans[i]+=z/y;
all-=ans[i];
z%=y;
a[i].d=z;
a[i].no=i;
}
sort(a+,a+n+,cmp);
for(i=n-all+;i<=n;i++)
ans[a[i].no]++;
for(i=;i<=n;i++)
printf("%d ",ans[i]);
puts("");
return ;
}
100197G Robbers的更多相关文章
- Codeforces Round #359 (Div. 2)C - Robbers' watch
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces 359 C - Robbers' watch
Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Robb ...
- UVA1616-Caravan Robbers(枚举)
Problem UVA1616-Caravan Robbers Accept: 160 Submit: 1156Time Limit: 3000 mSec Problem Description O ...
- UVA1616-Caravan Robbers(二分)
Problem UVA1616-Caravan Robbers Accept: 96 Submit: 946Time Limit: 3000 mSec Problem Description Lon ...
- Codeforces 658A. Robbers' watch 模拟
A. Robbers' watch time limit per test: 2 seconds memory limit per test: 256 megabytes input: standar ...
- Codeforces Round #359 (Div. 1) A. Robbers' watch 暴力
A. Robbers' watch 题目连接: http://www.codeforces.com/contest/685/problem/A Description Robbers, who att ...
- SCOJ 4484 The Graver Robbers' Chronicles 后缀自动机
4484: The Graver Robbers' Chronicles 题目连接: http://acm.scu.edu.cn/soj/problem.action?id=4484 Descript ...
- Codeforces Round #359 (Div. 2) C. Robbers' watch 鸽巢+stl
C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces 686C C. Robbers' watch(dfs)
题目链接: C. Robbers' watch time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
随机推荐
- 三目运算符与if else的运行效率
两者的效率比较: 当比较次数较少时,效率一样: 当比较次数较多时,发现ifelse的速度更快,应该是其汇编指令更少的原因. if else的汇编代码如下: 三目运算符代码如下:
- 使用手势对UIImageView进行缩放、旋转和移动(转)
原文地址:http://blog.csdn.net/crazy_frog/article/details/8664108 // 添加所有的手势 - (void) addGestureRecognize ...
- rpy2的安装问题?【解决】
https://www.zhihu.com/question/46555829 http://blog.sciencenet.cn/blog-365459-901335.html
- uoj#87. mx的仙人掌
//Achen #include<bits/stdc++.h> #define For(i,a,b) for(int i=(a);i<=(b);i++) #define Rep(i, ...
- Rabbitmq用户权限配置
由于账号guest具有所有的操作权限,并且又是默认账号,出于安全因素的考虑,guest用户只能通过localhost登陆使用,并建议修改guest用户的密码以及新建其他账号管理使用rabbitmq(该 ...
- C#中将dateTimePicker初始值设置为空
最近在做一个小项目,有一个功能是根据用户选择条件查询数据,要求时间控件的默认值为空,只有当用户修改了时间,才根据时间查询.简单的说,就是默认或者点击清空按钮的情况下,时间控件dateTimePicke ...
- NAT路由器打洞原理
什么是打洞,为什么要打洞 由于Internet的快速发展 IPV4地址不够用,不能每个主机分到一个公网IP 所以使用NAT地址转换. 下面是我在网上找到的一副图 一般来说都是由私网内主机(例如上图中“ ...
- electron 安装失败解决办法
1.安装node https://nodejs.org/en/download/2.安装镜像工具npm install -g cnpm --registry=https://registry.npm. ...
- java服务覆盖率统计 jacoco ant
● 下载jacoco.exec.jacocoant.jar.jacocoagent.jar ● jvm启动参数中添加(tomcat服务原理一样) JACOCO_OPTS=JAVA_OPTS=" ...
- Sql server big data如何批量update数据
原因: 要一次性update 2千万条数据,虽然update sql很简单,但是由于一次性修改太多的数据,造成数据库log满了,就会报error: [ErrorCode: 9002, SQL Stat ...