Problem J. Journey with Pigs
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的更多相关文章
- codeforces gym100801 Problem J. Journey to the “The World’s Start”
传送门:https://codeforces.com/gym/100801 题意: 小明坐地铁,现在有n-1种类型的地铁卡卖,现在小明需要买一种地铁票,使得他可以在t的时间内到达终点站,地铁票的属性为 ...
- poj 3544 Journey with Pigs
Journey with Pigs Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3004 Accepted: 922 ...
- 实验12:Problem J: 动物爱好者
#define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web B ...
- Codeforces Gym 100342J Problem J. Triatrip 求三元环的数量 bitset
Problem J. Triatrip Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- 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, ...
- Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...
- Problem J: 求个最大值
Problem J: 求个最大值 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 871 Solved: 663[Submit][Status][Web ...
- 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 ...
- 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 ...
随机推荐
- 走进Java中的持有对象(容器类)之一 容器分类
Java容器可以说是增强程序员编程能力的基本工具,本系列将带您深入理解容器类. 容器的用途 如果对象的数量与生命周期都是固定的,自然我们也就不需要很复杂的数据结构. 我们可以通过创建引用来持有对象,如 ...
- django系列3 :创建模型
1创建模型 在我们简单的民意调查应用程序中,我们将创建两个模型:Question和Choice.A Question有问题和出版日期.A Choice有两个字段:选择的文本和投票记录.每个Choice ...
- django+mysql简单总结
1.工程下建立APP(以WIN10+PYTHON3.6为例) C:\Users\WYS>django-admin startproject myweb #建立项目 C:\Users\WYS&g ...
- 验证性控件的使用--验证两个文本框至少有一个不为空CustomValidator
转:http://blog.163.com/zhaowencong_2010/blog/static/20402815220122103155643/ 有时候我们在注册一个帐号时要求我们留下电话号码, ...
- 第三节:ThreadPool的线程开启、线程等待、线程池的设置、定时功能
一. ThreadPool简介 ThreadPool简介:ThreadPool是一个线程池,当你需要开启n个线程时候,只需把这个指令抛给线程池,它将自动分配线程进行处理,它诞生于.Net 2.0时代. ...
- SpringBoot系列:Pojo validation
JSR 303 规范了bean validation, Hibernate validator实现了JSR 303所有的规范, 同时也是最常用的validator 工具包. 使用 Hibernate ...
- 滚动锚定(Scroll Anchoring)- 让视口内容不再因视口上方 DOM 元素的高度变化而产生跳动
不知道你有没有经历过这样的场景:当你打开一张“多图杀猫”的页面后,正一张图一张图边滚边看,在你刚准备定睛看某一张图的时候,这张图突然被它上面的内容挤到了视口下方,然后你赶紧把滚动条往下拉,试图追赶这张 ...
- UEditor调用上传图片、上传文件等模块
来源:https://www.cnblogs.com/lhm166/articles/6079973.html 说到百度富文本编辑器ueditor(下面简称ue),我不得不给它一个大大的赞.我们在网站 ...
- Log日志
Log.e("tag", "错误信息"); Log.w("tag", "警告信息"); Log.i("ta ...
- JDK8- interface接口可以写方法体了-- 惊 dt.jar包等
基本上所有的Java教程都会告诉我们Java接口的方法都是public.abstract类型的,没有方法体的. 但是在JDK8里面,你是可以突破这个界限的哦. == 一个类实现某个接口,必须重写接口中 ...