
greedy
coldfresh
那我们开始吧
展开
-
Leha and Function CodeForces - 841C (greedy)
Leha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, …, n]. For subset find minimal element in it. F(n, k) — mathemat原创 2017-11-19 18:23:07 · 377 阅读 · 0 评论 -
Sub-Bipartite Graph FZU - 2141 (贪心)
Given a simple undirected graph G with n vertices and m edges, your task is to select a sub-bipartite graph of G with at least m/2 edges. In the mathematical field of graph theory, a bipartite graph ...原创 2018-04-14 20:34:24 · 300 阅读 · 0 评论 -
Cleaning Shifts POJ - 2376(贪心)
Farmer John is assigning some of his N (1 <= N <= 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day i...原创 2018-04-13 23:00:10 · 295 阅读 · 0 评论 -
Distinct Values【2018 Multi-University Training Contest 1 D题】(构造)(贪心)
Problem Description Chiaki has an array of n positive integers. You are told some facts about the array: for every two elements ai and aj in the subarray a_l..r(l≤i<j≤r),ai≠ajr(l≤i<j≤r),ai≠ajr ...原创 2018-07-24 23:52:18 · 204 阅读 · 0 评论 -
【51nod】最复杂的数 (简单搜索)
基准时间限制:1 秒 空间限制:131072 KB 分值: 40 把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数。 例如:12的约数为:1 2 3 4 6 12,共6个数,所以12的复杂程度是6。如果有多个数复杂度相等,输出最小的。 Input 第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 100) 第2 - T ...原创 2018-08-28 13:19:36 · 440 阅读 · 0 评论 -
【51nod 1125】 交换机器的最小代价 (置换、贪心)
基准时间限制:1 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 有N台机器重量各不相等,现在要求把这些机器按照重量排序,重量从左到右依次递增。移动机器只能做交换操作,但交换机器要花费一定的费用,费用的大小就是交换机器重量的和。例如:3 2 1,交换1 3后为递增排序,总的交换代价为4。给出N台机器的重量,求将所有机器变为有序的最小代价。(机器的重量均为正整数) Input...原创 2018-09-06 15:18:28 · 430 阅读 · 0 评论 -
【Codeforces Round #530】Sum in the tree(贪心构造)
做法: 我之前错误的做法是从前往后推的,优先最小,但是显然这是错误的,随便构造一个就能找到反例,当时没什么时间了,就没有怎么仔细想。因为实际上当越往根节点靠近时,这个点值应该越大越好,因为他可以以他为根子树的贡献越多,使得总体所有点权和越小,这个从直觉上就可以分析出来应该是没有问题,所以这个应该得从后往前推,如果这个点的s值没确定,那么应该取他的子节点的的s值当中的最小值。如果发现他的子节点都...原创 2019-01-07 11:56:45 · 382 阅读 · 0 评论