大意:n个骑士, 每个骑士有战力p, 钱c, 每个骑士可以抢战力比他低的钱, 每个骑士最多抢k次, 对每个骑士求出最大钱数 按战力排序后, 堆维护动态前k大即可 #include <iostream> #include <algorithm> #include <cstdio> #include <queue> #define REP(i,a,n) for(int i=a;i<=n;++i) using namespace std; typedef l…
Knights of a Polygonal Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other.…
[程序结果:用例未完全通过,本博文仅为暂存代码之目的] /* B. Knights of a Polygonal Table url:http://codeforces.com/problemset/problem/994/B 思路: step0.对骑士进行编号 step1.按照权力值进行顺序排序 step2.分别计算骑士所能杀死的其他骑士及其对应的金币值 step3.按照编号重新恢复原始排序. */ //#include<bits/stdc++.h> #include<iostream…
http://codeforces.com/problemset/problem/994/B 题意: 给出n和m,有n个骑士,每个骑士的战力为ai,这个骑士有bi的钱,如果一个骑士的战力比另一个骑士的战力高,那么,他就可以夺取这个骑士的钱,但是每个骑士最多夺取m个人,问,这些骑士最多可以获得 多少钱. #include <stdio.h> #include <string.h> #include <iostream> #include <string> #i…
解题思路 将骑士按力量从小到大排序,到第i个骑士的时候,前面的i-1个骑士他都可以击败,找出金币最多的k个. 用multiset存金币最多的k个骑士的金币数,如果多余k个,则删除金币数最小的,直到只有k个数字. 我就是因为没有用multiset在最后5分钟被hack了. 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; int n,k; //输入,p表示力量,c表示金币,idx表示输入时的位置 stru…
有 n 个骑士想决战.每个骑士都有能力值(互不相同),且身上带有一些金币.如果骑士 A 的能力值大于骑士 B ,那么骑士 A 就可以杀死骑士 B ,并获得骑士 B 身上的所有金币.但就算是骑士也不会残忍过度,他们最多只会杀死 k 个骑士.对于每一位骑士,请你求出在杀掉所有他能杀的人(只有他能杀人别人不动)后他身上金币的最大值. Solution 注意到"互不相同"这个弱化条件,考虑对能力值从小到大排序,那么每个骑士能且只能杀他前面的人.所以动态维护前 \(k\) 大和就好了 (题意有点…
Arthur and Table CodeForces - 557C 首先,按长度排序. 长度为p的桌腿有a[p]个. 要使得长度为p的桌腿为最长,那么要按照代价从小到大砍掉sum{长度不到p的腿的数量}-a[p]+1条腿.还需要将所有长于p的桌腿砍光.枚举p即可. 要点(看了题解才明白):可以通过精力最高只有200的条件,大大缩小时间/空间复杂度. 恩,所以...这是贪心吧? #include<cstdio> #include<algorithm> using namespace…
Knights of the Round Table Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 12439   Accepted: 4126 Description Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the oth…
Knights of the Round Table Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 10911   Accepted: 3587 Description Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the oth…
Knights of the Round Table Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 9169   Accepted: 2960 Description Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the othe…