Problem J. Journey with Pigs
http://codeforces.com/gym/241680/problem/J
考察排序不等式
算出来单位重量在每个村庄的收益,然后生序排列
猪的重量也生序排列
此时价值最大

 #include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
long long n,t;
long long dis[];
struct value{
long long poi;
long long v;
}a[]; struct pig{
long long poi;
long long w;
}b[];
long long ans[]; void in(long long &x){
long long y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(long long x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} bool cmp1(pig a,pig b){
return a.w<b.w;
} bool cmp2(value a,value b){
return a.v<b.v;
} int main(){
freopen("journey.in","r",stdin);
freopen("journey.out","w",stdout);
in(n);in(t);
For(i,,n){
in(b[i].w);
b[i].poi=i;
}
sort(b+,b+n+,cmp1);
For(i,,n)
in(dis[i]);
For(i,,n){
in(a[i].v);
a[i].poi=i;
}
For(i,,n)
a[i].v=a[i].v-dis[i]*t;
sort(a+,a+n+,cmp2);
For(i,,n)
ans[a[i].poi]=b[i].poi;
For(i,,n-){
o(ans[i]);p(' ');
}
o(ans[n]); return ;
}

Problem J. Journey with Pigs的更多相关文章

  1. codeforces gym100801 Problem J. Journey to the “The World’s Start”

    传送门:https://codeforces.com/gym/100801 题意: 小明坐地铁,现在有n-1种类型的地铁卡卖,现在小明需要买一种地铁票,使得他可以在t的时间内到达终点站,地铁票的属性为 ...

  2. poj 3544 Journey with Pigs

    Journey with Pigs Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3004   Accepted: 922 ...

  3. 实验12:Problem J: 动物爱好者

    #define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web B ...

  4. Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset

    Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...

  5. The Ninth Hunan Collegiate Programming Contest (2013) Problem J

    Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...

  6. Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量

    Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...

  7. Problem J: 求个最大值

    Problem J: 求个最大值 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 871  Solved: 663[Submit][Status][Web ...

  8. 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题

    Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest ...

  9. XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem J. Terminal

    题目:Problem J. TerminalInput file: standard inputOutput file: standard inputTime limit: 2 secondsMemo ...

随机推荐

  1. django restframework permission

    与 authentication 和 throttling 一起,permission 决定是应该接受还是拒绝访问请求.权限检查总是在视图的最开始处运行,在任何其他代码被允许进行之前.权限检查通常会使 ...

  2. com.android.support:appcompat-v7:27.+问题解决

    新建的项目就报下面的错误,问题指向了app/build.gradle,看起来是版本兼容的问题.     解决方案: 1.查看sdk tools的版本:26.1.1   远程依赖包是27.+,而我们的s ...

  3. hotplug/mdev机制

    目录 hotplug/mdev机制 框架 kobject_uevent_env mdev_main make_device mdev.conf 配置文件学习 更改属性 @:创建设备节点之后执行命令 $ ...

  4. 第十二节:Lambda、linq、SQL的相爱相杀(1)

    一. 谈情怀  Lambda.Linq.SQL伴随着我的开发一年又一年,但它们三者并没有此消彼长,各自占有这一定的比重,起着不可替代的作用. 相信我们最先接触的应该就是SQL了,凡是科班出身的人,大学 ...

  5. CSS难点 为什么height设置100%会失效,分栏目等高布局(高度自适用布局)的实现方案

    前言 相信在平时写CSS的时候大家都或多或少遇见过设置了height为百分比的时候发现不起作用.今天我们就来一探究竟 原因:父元素未设置具体高度,子元素设置height:100%是无效的. 现象以及方 ...

  6. [再寄小读者之数学篇](2014-06-22 函数恒为零的一个充分条件 [中国科学技术大学2011年高等数学B考研试题])

    设 $f(x)$ 在 $\bbR$ 上连续, 又 $$\bex \phi(x)=f(x)\int_0^x f(t)\rd t \eex$$ 单调递减. 证明: $f\equiv 0$. 证明: 设 $ ...

  7. Java之final关键字详解

    1. 修饰类 当用final去修饰一个类的时候,表示这个类不能被继承. 注意: a. 被final修饰的类,final类中的成员变量可以根据自己的实际需要设计为fianl. b. final类中的成员 ...

  8. APPLE-SA-2019-3-25-4 Safari 12.1

    APPLE-SA-2019-3-25-4 Safari 12.1 Safari 12.1 is now available and addresses the following: Safari Re ...

  9. MySQL学习6 - 完整性约束

    一 介绍 二 not null 与default 三 unique 四 primary key 五 auto_increment 六 foreign key 快速理解foreign key 创建两张表 ...

  10. 逻辑运算符、位运算符、三元运算符、判断语句(if,switch)

    逻辑运算符 逻辑与 &:由false则false 逻辑或 |:有true则true 逻辑异或 ^:相同为false,不同为true 逻辑非 !:非false则true,非true则false ...