3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 137 Solved: 89[Submit][Status][Discuss] Description Being a fan of all cold-weather sports (especially those involving cows), Farmer John wants to record a…
3433: [Usaco2014 Jan]Recording the Moolympics Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 55 Solved: 34[Submit][Status] Description Being a fan of all cold-weather sports (especially those involving cows), Farmer John wants to record as much of…
题意:给出n个区间[a,b),有2个记录器,每个记录器中存放的区间不能重叠.求2个记录器中最多可放多少个区间. 解法:贪心.只有1个记录器的做法详见--关于贪心算法的经典问题(算法效率 or 动态规划).而对于2个,就是在1个的基础上(按 bi 排序,选第一个与之前没有相交的区间)维护2个值,注意要好好for循环遍历一次O(n),若想着用while直接跳过一些区间很容易出错!!!另外,遍历时要先考虑能否把当前的区间接在之前右端点较右的记录器. 1 #include<cstdio> 2 #inc…
题面 Time Limit: 10 Sec Memory Limit: 128 MB Submit: 136 Solved: 90 [Submit][Status][Discuss] Description The cross-country skiing course at the winter Moolympics is described by an M x N grid of elevations (1 <= M,N <= 500), each elevation being in t…
不知道该叫贪心还是dp 倒着来,记f[0][i],f[1][i]分别为先手和后手从n走到i的最大值.先手显然是取最大的,当后手取到比先手大的时候就交换 #include<iostream> #include<cstdio> using namespace std; const int N=700005; int n,a[N],w=n; long long f[2][N],mx; int read() { int r=0,f=1; char p=getchar(); while(p&…
[bzoj 3048] [Usaco2013 Jan]Cow Lineup Description 给你一个长度为n(1<=n<=100,000)的自然数数列,其中每一个数都小于等于10亿,现在给你一个k,表示你最多可以删去k类数.数列中相同的数字被称为一类数.设该数列中满足所有的数字相等的连续子序列被叫做完美序列,你的任务就是通过删数使得该数列中的最长完美序列尽量长. Input Line 1: Two space-separated integers: N and K. Lines 2..…