B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera loves his garden, where n fruit trees grow. This year he will enjoy a great harvest! On the i-th tree bi fruit gr…
#include <iostream> #include <vector> #include <algorithm> #include <map> using namespace std; int main(){ int n,v; cin >> n >>v; map<int,int> fruit; ; i < n; ++ i ){ int a,b; cin >>a >> b; if(fruit…
英语不好就是坑啊.这道题把我坑残了啊.5次WA一次被HACK.第二题得分就比第一题高10分啊. 以后一定要加强英语的学习,要不然就跪了. 题意:有一个果园里有非常多树,上面有非常多果实,为了不然成熟的果实腐烂,必须在两天之内收集起来.给出果园有的树,以及该树上的果实个数,工人每天能够採集的上限,求出这段时间之后,能收集到的最大值. 想法非常easy.优先採集上一天剩下的果实(假设有剩下).假设还能採集再採集今天成熟的果实.假设採集不玩就把当前天数的果实移动到下一天去优先採集. #include<…
贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; typedef pair<int,int> Point; int main(){ ; cin >> n >> m >>k…
水题 #include <iostream> #include <set> #include <vector> #include <algorithm> using namespace std; int main(){ int n,v; cin >> n >> v; vector<int> res; ; i < n; ++ i){ int k,s; bool flag = false; cin >> k;…
layout: post title: Codeforces Round 252 (Div. 2) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces - 群论 --- 传送门 A.Valera and Antique Items (签到) 题意 如果当前钱数比一组数中最小的还要大就+1 思路 直接模拟 #include<bits/stdc++.h> using namespace std…
Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bough…
A. Valera and X time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn…
题目链接:http://codeforces.com/contest/369/problem/D 注意题意:所有fools都向编号最小的fool开枪:但每个fool都不会笨到想自己开枪,所以编号最小的fool向编号次小的fool开枪: 所以只需记录编号最小的两位成员即可代表一种状态:当然当只剩一个fool时,次小编号是不存在的出界元素. 编号最小的两个fools只有四种状态:a活b活,a死b死,a活b死,a死b活:注意状态转移条件. 记忆化搜索即可(算法上依然是搜索的流程,但是搜索到的一些解用动…
http://codeforces.com/problemset/problem/441/D 置换群的基本问题,一个轮换内交换成正常顺序需要k-1次,k为轮换内元素个数 两个轮换之间交换元素,可以把两个轮换合并成1个,总交换次数+1 一个轮换内部交换,可以把一个轮换拆分成两个,总交换次数-1 #include <iostream> #include <cstdio> #include <cstring> #include <vector> using nam…
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int n,k,l,r,s_n,s_k; cin >> n >> k >> l >> r >> s_n >> s_k; int s_n_k = s_n-s_k; int average_k = s_k/k,left_k…
#include <iostream> using namespace std; int main(){ int n, m , k; cin >> n >> m >> k; , second_type = ; ; i < n ; ++ i){ int a; cin >> a; (a == ) ? first_type++ : second_type ++ ; } ; ){ wash_number = first_type - m; m =…
思路:dp[i][now][mark][len]   i 表示当前第i 次now存的是后8位,mark为第9位为0还是1 len第九位往高位还有几位和第9位相等.  只存后8位的原因:操作只有200次每次都为加法的话后8位可以表示,如果为乘法第八位已知再加上第九位 和往前的长度已知,所以可以表示所有状态. 所存在问题就是 10 1111 1111 此时加上1之后 会变成 11 0000 0000 但这样并处影响结果 如果之后操作都为加法,只有200次,他不可能影响到前面的1, 乘法相当于左移也不…
题意:n个线段[Li, Ri], m次询问, 每次询问由cnt个点组成,输出包含cnt个点中任意一个点的线段的总数. 由于是无修改的,所以我们首先应该往离线上想, 不过我是没想出来. 首先反着做,先求不包含这个cnt个点的线段的总数, 那么不包含这些点的线段必然在cnt个点之间(这里需要再加两个点一个是0, 一个是MAX), 我们可以把所有线段按Ri 分类, 然后按右端点遍历,对于当前的线段可以在Li 处+1, 然后对于每一次询问中两个点(x, y)之间线段的个数, 只需要查询 左端点大于等于x…
题目倒是不难,可是读起来非常恶心 依据题目的描写叙述不easy找到适合存储的方法 后来我就想不跟着出题人的思路走 我自己开一个数组c 令c[a[i]] = b[i] 则c[i] == [j] 代表第i天相应有j个果子成熟 接着用贪心的方法做就好了 当前天尽可能收取昨天的果子.在收完的情况下再考虑今天的果子 代码例如以下: #include <cstdio> #include <iostream> #include <algorithm> #define MAXN 100…
标题效果: 给很多分布 x 行轴. 然后给出了一个非常的多点集,问该组点分布多少不同段. IDEAS: 分散成多个线段点集的. 给出的线段的话,也就是说这个点集上不会有点在这条线段上. 所以我们就是求出 点集做出的线段包括了多少个给出的线段就能够了. 那么也就是比較l r的大小,排序之后用BIT #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #def…
C题就是一个简单的模拟.首先给每一个人两个.然后把剩下的都给一个人就好了. 给的时候蛇形给. #include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> #include<vector> #include<queue> using namespace std; #define LL __int64 #define maxn 330000 int…
题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmemory limit per test256 megabytes 问题描述 Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that pla…
B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/B Description Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any o…
D. Make a Permutation! time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Ivan has an array consisting of n elements. Each of the elements is an integer from 1 to n. Recently Ivan learned…
B. Text Document Analysis 题目连接: http://codeforces.com/contest/723/problem/B Description Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of cha…
B. Pyramid of Glasses 题目连接: http://www.codeforces.com/contest/676/problem/B Description Mary has just graduated from one well-known University and is now attending celebration party. Students like to dream of a beautiful life, so they used champagne…
E. Frog Fights 题目连接: http://www.codeforces.com/contest/625/problem/E Description stap Bender recently visited frog farm and was inspired to create his own frog game. Number of frogs are places on a cyclic gameboard, divided into m cells. Cells are nu…
http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来考试) 那么这个all值就是理想的最小值.然后去前all个数找,贪心地复习最小的科目,然后有的考试的话,就优先考试. 如果经过这all天,复习完了(这个是肯定得),但是只是因为时间分配不好,导致没得考试(数据导致没得考试) 那么就暴力枚举后面的[all + 1, n].有得考试就去考试,刚好考完就直…
原题连接:http://codeforces.com/contest/580/problem/A 题意: 给你一个序列,问你最长不降子串是多长? 题解: 直接模拟就好了 代码: #include<iostream> using namespace std; int n; int main() { cin.sync_with_stdio(false); cin >> n; int p; cin >> p; ) { cout << << endl;…
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果操作了很多次仍不能分出胜负,则认为平手.(至于多少次,我也不知道,只能写大一点碰运气,但要防止超时) 代码如下: #include<iostream>//C - Soldier and Cards #include<cstdio> #include<cstring> #in…
题目链接:http://codeforces.com/contest/448/problem/B ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma…
F. Restore a Number   Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n. Magically, all the numbers were shuffled in arbitrary order whil…
C. Balls and Boxes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from…
C. Epidemic in Monstropolis time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There was an epidemic in Monstropolis and all monsters became sick. To recover, all monsters lined up in queue fo…