K. Malek and Summer Semester   time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output Malek registered n courses for the summer semester. Malek has a success rate m, which means he has to succeed at least i…
K. Malek and Summer Semester time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output Malek registered n courses for the summer semester. Malek has a success rate m, which means he has to succeed at least in …
这几天一直在宿舍跑PY模型,学校的ACM寒假集训我也没去成,来学校的时候已经18号了,突然加进去也就上一天然后排位赛了,没学什么就去打怕是要被虐成渣,今天开学前一天,看到最后有一场大的排位赛,就上去试了一下,果然被虐成渣,十二道题目在有限时间内就做了四道,还有一道疯狂的WA,拿出两道一些有趣的想法出来分享一下. 今天打题就遇到了大数计算的问题,本来昨晚想解决这个难题,也没来得及,所以打题的时候大数计算那道就放弃了,过几天我一定会扔上来的. 今日兴趣新闻: 年度最惨小学生!在姥姥家热炕头写作业,写…
传送:http://codeforces.com/gym/102152/problem/K 题意:给定$n(n\le10^5)$个数$a_i(a_i\le10^9)$,对于任一个子数组中的数进行或操作,问所有的值有多少种? 分析: 假设现在想要求解区间$[1,i]$内的答案,那么需要先处理出$[1,i-1],[2,i-1],[3,i-1]......[i-1,i-1]$.然后将这些答案暴力与$a_i$取$|$. 代码: #include<bits/stdc++.h> using namespa…
题目链接:http://codeforces.com/contest/1133/problem/E 题目大意: 在n个人中找到k个队伍.每个队伍必须满足最大值减最小值不超过5.求满足条件k个队伍人数的总和的最大值. 这个题写DP很多的人应该可以很快写出来吧,毕竟不是很难. 思路: 反正最多n^2种状态.用数组存就好了. 先排序. 对于每个点,dp[a][b].表示a到n区间里分b个队伍的答案. 如果a是答案dp[a][b]所需要的,那么我们从a开始到a+i暴力一下(此时,x[a+i]-x[a]>…
题目链接:https://codeforces.com/contest/1133/problem/C 题意: 给出 $n$ 个数,选取其中若干个数分别组成 $k$ 组,要求每组内最大值与最小值的差值不超过5,求 $k$ 组合起来最多可以放多少个数. 题解: 将 $a[1 \sim n]$ 从小到大排序,排序后每个组必定可以视为数组 $a$ 上一段连续区间, $f[i][j]$ 表示到第 $i$ 个数为止,前面组成 $j$ 组,最多可以包含多少个数. 那么,考虑第 $i$ 个数选取与否,如果不选,…
链接:https://codeforces.com/contest/1269/problem/E 题意:给一个序列P1,P2,P3,P4....Pi,每次可以交换两个相邻的元素,执行最小次数的交换移动,使得最后存在一个子段1,2,…,k,这是题目所定义的f(k),题目要求求出所有的f(n),并依次输出. 思路:首先考虑逆序对问题,比如3 2 1 4这个序列,要使其变为1 2 3 4,最小的移动次数是这个序列中逆序对之和,2+1 = 3,逆序对是(3,2) (3,1)(2,1),但是在比如序列3…
链接 https://codeforces.com/contest/1282/problem/B2 题意: 商店买东西,商店有n个物品,每个物品有自己的价格,商店有个优惠活动,当你买恰好k个东西时可以只为其中最贵的那个付款,求有限的钱中买到的最多的物品数量,你可以多次使用优惠. 思路:把所有商品的价格排序从小到大一遍,设第i个物品的价格是a[i],Sum[i]表示购买前i个物品花费的钱,作为前缀和.可以发现当你买了当第i个物品时,那么只需要支付Sum[i-k] + a [i] 即可,因为你买了当…
题目: You are a coach at your local university. There are nn students under your supervision, the programming skill of the ii-th student is aiai. You have to form kk teams for yet another new programming competition. As you know, the more students are…
I. Move Between Numbers   time limit per test 2.0 s memory limit per test 256 MB input standard input output standard output You are given n magical numbers a1, a2, ..., an, such that the length of each of these numbers is 20 digits. You can move fro…