CodeForces 665B 【水-暴力】】的更多相关文章

题意: 要生产n个物品,每个花费时间为x. 有两种魔法,每种最多使用1个. 其中第一种魔法可以使每个物品生产的花费时间变为ai,相应的花费是bi;第二种魔法可以减少ci个物品,相应的花费是di,并且保证对于i<j ci<=cj 且 di<=dj; #include<bits/stdc++.h> using namespace std; ],c[],d[]; pair<]; long long inf=0x3f3f3f3f3f3f3f3f; int main() { lo…
A.喵哈哈村的魔法石 发布时间: 2017年2月21日 20:05   最后更新: 2017年2月21日 20:06   时间限制: 1000ms   内存限制: 128M 描述 传说喵哈哈村有三种神奇的魔法石:第一种魔法石叫做人铁石,拥有A的能量:第二种魔法石叫做地冈石,拥有B的能量:而第三种,则是最神奇的天玄石,拥有无可比拟的C的能量! 但是有一天,沈宝宝太调皮了,把一颗天玄石玩丢了…… “这可玩大发了,这样我会被天行廖责备的.”沈宝宝悲伤的说到,“怎么办呢?” 这时候沈宝宝望了望窗外的飞过…
题意(来自网络): 现在有k件商品,每个商品的位置已经告诉你了 现在有n个人,每个人有m个需求,每个需求就是要把第a[i][j]个物品拿到第一个位置来 他的代价是pos[a[i][j]] 问你所有代价是多少 思路: 就是每次+,每次调整,还有滚动数组这种不错欸~ #include <bits/stdc++.h> using namespace std; typedef __int64 LL; int pos[2][110]; int main() { int n,m,k; scanf(&quo…
A. Anton and Polyhedrons time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Anton's favourite geometric figures are regular polyhedrons. Note that there are five kinds of regular polyhedrons:…
A. Anastasia and pebbles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she…
题目链接: B. Shopping time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Ayush is a cashier at the shopping center. Recently his department has started a ''click and collect" service which allow…
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output ZS the Coder is coding on a crazy computer. If you don't type in a word for a c consecutive seconds, everything you typed…
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cma…
A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. Afte…
A B C 给你N(N<=30)种水瓶每种水瓶有无限个 每个的体积是2^(i-1)价格是cost[i] 要求你花最少的钱弄出L体积的水 先从前到后扫一遍cost[i+1]=min(cost[i+1],cost[i]*2)  再从后往前扫一遍cost[i]=min(cost[i],cost[i+1) 保证了价格的最优化 然后从0开始到30 如果二进制有当前体积的就买 同时检验一下anser=min(anser,cost[i+1])(意思是如果买当前所有体积两倍的水比买当前的便宜就买当前体积两倍的)…
Codeforces-566F 题目大意:给出一个有序数列a,这个数列中每两个数,如果满足一个数能整除另一个数,则这两个数中间是有一条边的,现在有这样的图,求最大联通子图. 题解:并不需要把图搞出来,可以直接dp,$f[i]$表示以第$i$个数为开头的最大的联通子图,转移类似最长上升子序列,$f[i]=max(f[i],f[j]+1)$ Code: #include<iostream> #include<cstdio> #include<algorithm> #incl…
On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as follows. In each level, you have a grid with n rows and mcolumns. Each cell originally contains the number 0. One move consists of choosing one row or c…
Chladni Figure CodeForces - 1162D Inaka has a disc, the circumference of which is nn units. The circumference is equally divided by nn points numbered clockwise from 11 to nn, such that points ii and i+1i+1 (1≤i<n1≤i<n) are adjacent, and so are poin…
暴力 #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<algorithm> using namespace std; int n,m,k; ],b[]; int pos(…
The only difference between easy and hard versions is a number of elements in the array. You are given an array aa consisting of nn integers. The value of the ii-th element of the array is aiai. You are also given a set of mm segments. The jj-th segm…
题目链接:http://codeforces.com/problemset/problem/589/D 题目大意:给出n个人行走的开始时刻,开始时间和结束时间,求每个人分别能跟多少人相遇打招呼(每两人只能打招呼一次). 例: 输入:31 1 105 8 29 9 10 输出: 2 1 1 解题思路:先按行走的开始时刻排下序,然后直接模拟判断和比他后出现的人是否可以相遇. 第一步判断前面那个人在未走完前,下一人会出现,若不出现,直接break.然后就计算当下一个人出现的时刻,前一个人的位置,然后又…
题目链接:http://codeforces.com/problemset/problem/589/B 题目大意:告诉你n 个矩形,知道矩形的长度和宽度(长和宽可以互换),每个矩形的长度可以剪掉一部分,宽度也同样,求出可以得到多少个一样(每个矩形的长相等,宽也相等)的矩形,使得面积之和最大,并输出长和宽. 解题思路:将每个矩形的长和宽都存到一个结构体数组内,对矩形的长进行排序,因为最终结果的长一定是某个矩形的长,宽也一定是某个矩形的宽,所以我们枚举长,然后将长大于等于该长度的矩形的宽加入到一个向…
Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n rectangular cake layers. The length and the width of the i-th cake layer were ai and birespectively, while the height of each cake layer was equal to…
题目传送门 传送门I 传送门II 传送门III 题目大意 求一个满足$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil - \sum_{i = 1}^{n} a_{i} \leqslant K$的最大正整数$d$. 整理一下可以得到条件是$d\sum_{i = 1}^{n} \left \lceil \frac{a_i}{d} \right \rceil \leqslant K + \sum_{i = 1}^{n} a_{i}$…
题目:http://codeforces.com/problemset/problem/620/C 文章末有一些测试数据仅供参考 题目大意 给你一个数字串,然后将分成几个部分,要求每个部分中必须有一对儿相等的数字,每个数字都属于某个部分,输出划分的部分数量以及对应区间.  思路 很简单一道题,输入的数据都不用存的,输入一个检测一个就好了,用map打标记,用容器存一下要输出的区间端点值,最后挨个儿输出就好了 代码如下: #include<iostream> #include<map>…
A. Message time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. String p is called a substring of string s if you…
Codeforces17A 题意: 有一种素数会等于两个相邻的素数相加 如果在2~n的范围内有至少k个这样的素数,就YES,否则就NO; 思路: 采用直接打表,后面判断一下就好了.那个预处理素数表还是满赞的~~ 不多说,上code-----. #include<bits/stdc++.h> #include<string.h> using namespace std; typedef long long LL; typedef unsigned long long ULL; con…
纯暴力..... B. Towers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you know, all the kids in Berland love playing with cubes. Little Petya has n towers consisting of cubes of the same si…
A. Cookies time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Olga came to visit the twins Anna and Maria and saw that they have many cookies. The cookies are distributed into bags. As there…
I - 9 Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 327B Description Iahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead o…
题目链接 题意:给平均成绩和科目数,求可能的最大学分和最小学分. 分析: 枚举一下,可以达到复杂度可以达到10^4,我下面的代码是10^5,可以把最后一个循环撤掉. 刚开始以为枚举档次的话是5^10,但是这个又不要求顺序,所以只是枚举个数就行了.. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #includ…
Sum of sequencesTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/B Description You finished RIUSB ACBJSO university few years ago and started working hard and growing your carrier. At th…
题意:1000个元素,每个元素的大小-1e9<=a[i]<=1e9,然后让你重新安排这些元素的位置 获得最长的前缀斐波那契数列 分析:枚举第一个元素和第二个元素,因为在题目元素的范围内,最多形成长度为90的斐波那契数列 除非有全0的情况出现,这种情况会达到长度1000 所以这种情况特判一下(记录一下零元素的个数就行了) 然后枚举是n^2的 找元素是90,然后找的时候,我用的map来找 所以时间复杂度是略大是O(90n^2logn) 所以由于不可能每次都找到90,所以均摊比较小,这题时限是3s,…
题目大意:有N个球K个人,现在要给这N个球涂上K种颜色,要求使抽到球的不同颜色的概率一致(N确保是K的倍数),求出来至少要给多少个球重新涂上颜色. 分析:先求出来所有球的每种颜色的个数,然后不到平均数的加上距离平均数的个数即可. 代码如下: ---------------------------------------------------------------------------------------------------------------------------------…
A. Cifera time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output When Petya went to school, he got interested in large numbers and what they were called in ancient times. For instance, he learned…