D. Yet Another Monster Killing Problem You play a computer game. In this game, you lead a party of…
题意:给定一些怪物,每天可以选一个勇士进去打怪,每个勇士每天只能打不超过si个怪物,每个勇士只能打能力值≤pi的怪物,问最少多少天打完所有怪物 题解:贪心,每天尽可能多的去打怪,那么存一个对于长度为i的怪物可以用的最大的能力值是多少,每天枚举长度,尽可能长的去打怪即可 代码: #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<string&g…
You play a computer game. In this game, you lead a party of mm heroes, and you have to clear a dungeon with nn monsters. Each monster is characterized by its power aiai. Each hero is characterized by his power pipi and endurance sisi. The heroes clea…
题目连接: https://codeforces.com/contest/1257/problem/D 题目大意: n个怪兽,m个英雄,每个怪兽有一定的能力值,每个英雄有一定的能力值和一定的耐力值.耐力值得含义是每天可以击杀怪兽的最多数目.当英雄的能力值大于怪兽的能力值时,英雄可以击杀怪兽,然后问击杀 所有的怪兽所需要的最短时间,如果不能击杀所有怪兽,输出-1: 思路:主要是一个对一个mx数组的理解mx[i]的含义是在耐力值为i的情况下,英雄的最大能力. #include<bits/stdc++…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
题目链接: B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Andrey needs one more problem to conduct a programming contest. He has n friends who are always willing to help.…
Bob and math problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 401    Accepted Submission(s): 149 Problem Description Recently, Bob has been thinking about a math problem.There are N Digit…
HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 签到题,非常easy贪心得到答案是(sum + 1) / 2和ai最大值的最大值 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N =…
D. Dasha and Very Difficult Problem 题目连接: http://codeforces.com/contest/761/problem/D Description Dasha logged into the system and began to solve problems. One of them is as follows: Given two sequences a and b of length n each you need to write a se…
B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as f…
An Easy Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8333   Accepted: 4986 Description As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.…
题目链接 Dasha and Very Difficult Problem 求出ci的取值范围,按ci排名从小到大贪心即可. 需要注意的是,当当前的ci不满足在这个取值范围内的时候,判为无解. #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i(a); i <= (b); ++i) + ; int a[N], b[N], c[N], op[N]; int l, r, L, R, cnt; b…
传送门 D. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated…
题目链接: Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 363    Accepted Submission(s): 134Special Judge Problem Description Everyone hates ugly problems.You are given a positive integ…
题目链接:http://codeforces.com/problemset/problem/798/C 题意:给你n个数,a1,a2,....an.要使得gcd(a1,a2,....an)>1,可以执行一次操作使ai,ai+1变为ai - ai + 1, ai + ai + 1.求出使得gcd(a1,a2,....an)>1所需要的最小操作数. 解题思路:首先,要知道如果能够实现gcd(a1,a2,....an)>1,那么a1~an肯定都是偶数(0也是偶数),所以我们的目的就是用最少的操…
题目链接: B. Clique Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulate…
描述As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form. Given a positive integer I, you task is to find out an integer J, which is the minimum integer greater than…
题目链接:http://codeforces.com/contest/761/problem/D D. Dasha and Very Difficult Problem time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Dasha logged into the system and began to solve problem…
题意: 给定n<=1000个小兵,A每次都能使小兵掉1点血,B每次能使所有小兵掉1点血,A.B轮流攻击,每次轮到A他会选择是否攻击,轮到B必须攻击.求A最多能杀死多少小兵.(当小兵血量为1时被攻击到视为被杀死) 思路: 如果所有小兵血量都不一样,A必定能杀死所有小兵.如果有小兵血量相同,那么A必定会攻击一些小兵使他们血量不同.所以我们可以把A的攻击分为两类:用来刚好杀死小兵的一次, 和用来使小兵血量不同的攻击. 我们可以用贪心的思想预处理出怎样用最小的攻击次数让小兵的血量都不同. 然后我们可以用…
数轴上有n 个点,第i 个点的坐标为xi,权值为wi.两个点i,j之间存在一条边当且仅当 abs(xi-xj)>=wi+wj. 你需要求出这张图的最大团的点数. Solution 把每个点看作以 \((x_i,0)\) 为圆心,半径为 \(r_i\) 的圆 那么如果不相交就有边相连 干脆看作线段吧,所以就是求最大不相交线段数 这就是一个很基础的贪心,以右端点为第一关键字,左端点为第二关键字 sort 然后"能取就取"即可 #include <bits/stdc++.h>…
题意 题目链接 给出一棵树,每个节点有权值,选出\(k\)个联通块,最大化 \[\frac{\sum_{i \in S} a_i}{k}\] Sol 结论:选出的\(k\)个联通块的大小是一样的且都等于最大联通块的大小 证明:因为我们是在保证分数最大的情况下才去最大化\(k\),一个很经典的结论是单独选择一个权值最大的联通块得到的分数一定是最大的,然后我们这时我们才去考虑最大化\(k\) 那么思路就很清晰了,先一遍dfs dp出最大联通块,然后再一遍dfs从下往上删就行了 #include<bi…
用(a,b)表示一个点先失去a点HP,然后增加b点HP 首先容易证明忽略父亲条件下,任意两个点,先吃b大的最优 对于一个节点v和它的父节点u,若此时选v最优,那么就是吃到u时可以立即吃掉v, 于是可以将u和v合并表示吃掉u时立即吃v,然后v的子节点连到u上 于是用一个堆维护节点,并查集找父亲 Code #include <cstdio> #include <algorithm> #include <queue> #include <cstring> #def…
Description Famil Door wants to celebrate his birthday with his friends from Far Far Away. He has n friends and each of them can come to the party in a specific range of days of the year from ai to bi. Of course, Famil Door wants to have as many frie…
题中只有两个条件:任意区间异或值不等于0或m. 如果只考虑区间异或值不等于 0,则任意两个前缀异或值不能相等. 而除了不能相等之外,还需保证不能出现任意两个前缀异或值不等于m. 即 $xor[i]$^$xor[j]!=m$, $\Rightarrow$ m^xor[j] 这个异或前缀就不可以再次出现了. 用一个数组标记一下就好了~ #include <bits/stdc++.h> #define N 1000000 #define setIO(s) freopen(s".in&quo…
CF Educational Round 78 (Div2)题解报告A~E A:Two Rival Students​ 依题意模拟即可 #include<bits/stdc++.h> using namespace std; int T; int n, x, a, b; int main() { cin >> T; while(T--) { cin >> n >> x >> a >> b; if(a > b) swap(a, b…
传送门 A. Two Rival Students 签到. Code /* * Author: heyuhhh * Created Time: 2019/11/13 22:37:26 */ #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #defi…
http://acm.hdu.edu.cn/showproblem.php?pid=4976 2014 Multi-University Training Contest 10 1006 A simple greedy problem. Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 20    Accepted Submission(s…
Description The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that…
ZOJ Problem Set - 3829Known Notation(贪心) 题目链接 题目大意:给你一个后缀表达式(仅仅有数字和符号),可是这个后缀表达式的空格不幸丢失,如今给你一个这种后缀表达式,问最少须要多少操作能够把这个表达式变成合法的. 操作: 1.在这个表达式的不论什么位置插入''或者数字(一位数). 2.把这个表达式的不论什么两个位置的字符对换. 解题思路: 一開始想的好复杂,结果还是漏了某种情况,一直过不去:就是卡在了碰到''的时候,数字不够是插入好还是替换好. 事实上仅仅要…
Problem UVA11134-Fabled Rooks Accept: 716  Submit: 6134Time Limit: 3000mSec Problem Description We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions• The i-th rook can only be placed within the rectangl…