传送门 题意简述:大家在数轴上生活,公司在 s. 班车送所有人回家,有 n 个住处,第 i 个位置在 xi,居住了 pi 的人. 保证 xi 互不相同. 大家⼀起投票向前还是向后,如果票数相同就固定向数轴负方向,每个⼈是自私的,希望自己尽早回家. (但是注意,虽然是自私的,并不⼀定投自己家的方向) 到家了必须下车(因为自私) 问大家都做最优决策的情况下,最后⼀个回家的人需要多久到家? 车速为 1. this is an easy problem. 事实上,这题我们应该倒着思考,对于最后的两队人:…
传送门 题意:给你x个a,y个b,z个c,显然这些字符可以拼成若干字符串,然后求这些字符串中最小表示法表示出来的最大的那一个. 解法:贪心思想,用multiset维护现在拼成的字串,每次取一个最小的和一个最大的拼在一起,最后剩下的就是答案. 代码如下: #include<bits/stdc++.h> using namespace std; int a,b,c; multiset<string>s; int main(){ scanf("%d%d%d",&…
http://www.cnbc.com/2016/07/12/tensions-in-south-china-sea-to-persist-even-after-court-ruling.html The judgment is not important. Arbitration that is only agreed on by one party is nothing more than toilet paper. This is my land; why should I let som…
传送门 一道挺有意思的贪心. 从1到n依次满足条件. 注意要特判第一个数已经大于x的情况. 但是如何贪心吃呢? 如果靠左的数没有越界,我们吃靠右的数. 原因是下一次靠右的数就会成为靠左的数,相当于多贡献了一次. 然后貌似要开long long 代码: #include<bits/stdc++.h> #define N 100005 #define ll long long using namespace std; ll a[N],x,ans=0; int n; inline ll read()…
传送门 昨晚打比赛的时候不是很机智啊. 这道题贪心就能过了. 我们可以发现一个明显的结论,每次选的垃圾的距离从大到小排序之后,每个距离对答案的贡献的系数是5,5,7,9,11-也就是最远的是5,其余都是2*rank+1. 这样就可以根据每次选几个垃圾来贪心. 代码: #include<bits/stdc++.h> #define ll long long #define N 200005 using namespace std; inline int read(){ int ans=0; ch…
Area Time Limit: 1000MS Memory Limit: 10000K Description Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new research and development facility the company has…
Space Ant Time Limit: 1000MS Memory Limit: 10000K Description The most exciting space discovery occurred at the end of the 20th century. In 1999, scientists traced down an ant-like creature in the planet Y1999 and called it M11. It has only one eye o…
Wall Time Limit: 1000MS Memory Limit: 10000K Description Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals…