USACO Section 3.4: Raucous Rockers
简单的dfs题目
/* ID: yingzho1 LANG: C++ TASK: rockers */ #include <iostream> #include <fstream> #include <string> #include <map> #include <vector> #include <set> #include <algorithm> #include <stdio.h> #include <queue> #include <cstring> #include <cmath> #include <list> #include <cstdio> #include <cstdlib> #include <limits> #include <stack> using namespace std; ifstream fin("rockers.in"); ofstream fout("rockers.out"); int N, T, M; ]; ; void dfs(int leftvol, int diskdep, int songdep, int recsong) { if (diskdep == M) { maxnum = max(maxnum, recsong); return; } if (songdep == N) { maxnum = max(maxnum, recsong); return; } , recsong+); , songdep, recsong); dfs(leftvol, diskdep, songdep+, recsong); } int main() { fin >> N >> T >> M; ; i < N; i++) fin >> songs[i]; dfs(T, , , ); fout << maxnum << endl; ; }
USACO Section 3.4: Raucous Rockers的更多相关文章
- USACO 3.4 Raucous Rockers
Raucous Rockers You just inherited the rights to N (1 <= N <= 20) previously unreleased songs ...
- 洛谷P2736 “破锣摇滚”乐队 Raucous Rockers
P2736 "破锣摇滚"乐队 Raucous Rockers 21通过 52提交 题目提供者该用户不存在 标签USACO 难度普及+/提高 提交 讨论 题解 最新讨论 暂时没有 ...
- USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)
usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...
- P2736 “破锣摇滚”乐队 Raucous Rockers
题目描述 你刚刚继承了流行的“破锣摇滚”乐队录制的尚未发表的N(1 <= N <= 20)首歌的版权.你打算从中精选一些歌曲,发行M(1 <= M <= 20)张CD.每一张C ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
- USACO Section 3.3 Camlot(BFS)
BFS.先算出棋盘上每个点到各个点knight需要的步数:然后枚举所有点,其中再枚举king是自己到的还是knight带它去的(假如是knight带它的,枚举king周围的2格(网上都这么说,似乎是个 ...
- [IOI1996] USACO Section 5.3 Network of Schools(强连通分量)
nocow上的题解很好. http://www.nocow.cn/index.php/USACO/schlnet 如何求强连通分量呢?对于此题,可以直接先用floyd,然后再判断. --------- ...
- USACO Section 5.3 Big Barn(dp)
USACO前面好像有类似的题目..dp(i,j)=min(dp(i+1,j),dp(i+1,j+1),dp(i,j+1))+1 (坐标(i,j)处无tree;有tree自然dp(i,j)=0) .d ...
- USACO Section 1.3 Prime Cryptarithm 解题报告
题目 题目描述 牛式的定义,我们首先需要看下面这个算式结构: * * * x * * ------- * * * <-- partial product 1 * * * <-- parti ...
随机推荐
- The finnacial statements,taxes and cash flow
This chapter-2 we learn about the the financial statements(财务报表),taxes and cash flow.We must pay par ...
- 百分比布局实现响应式布局在 IE6 中填坑思路
最近接了个政府项目,政府项目要求响应式,并且兼容IE6,不想用媒体监测的方法,于是用了百分比布局的方法,但是IE6真是名不虚传,做第一个界面就遇到了个bug ①两张宽度各占50%的图片无法在同一横排, ...
- Codeforces Round #131 (Div. 2) E. Relay Race dp
题目链接: http://codeforces.com/problemset/problem/214/E Relay Race time limit per test4 secondsmemory l ...
- bzoj 3039 悬线法求最大01子矩阵
首先预处理每个F点左右,下一共有多少个F点,然后 对于每个为0的点(R),从这个点开始,一直到这个点 下面第一个R点,这一区间中的min(左),min(右)更新答案. ps:我估计这道题数据有的格式不 ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
- [转载]115个Java面试题和答案
不知道大家有没有这样的体会,就是找工作的时候不得不准备大量面试题,而工作的时间长了面试题里的精髓却忘的差不多了... 转载几篇Java面试的bolg,温故而知新,最重要的是常来看看. 1. http: ...
- JAVA Hashmap不能用基本的数据类型
今天开始学习Java... 转载:http://moto0421.iteye.com/blog/1143777 今天试了一下HahsMap, 采用如下形似定义 (这个下面是用了csdn的一位同仁的文章 ...
- call by reference and copy/restore
转自:http://stackoverflow.com/questions/8848402/whats-the-difference-between-call-by-reference-and-cop ...
- JavaScript文件应该放在网页的什么位置
JavaScript文件应该放在网页的什么位置 http://www.lihuai.net/qianduan/js/352.html 在<良好的JavaScript编程习惯>系列教程的第三 ...
- C# 工厂
/// <summary> /// 创造实例 /// </summary> /// <typeparam name="T">类型</typ ...