题目大意: 输入N ( 1 ≤ N ≤ 20,000 ) :将一块木板分为n块 每次切割木板的开销为这块木板的长度,即将长度为21的木板分为13和8,则开销为21 接下来n行描述每块木板要求的长度Li ( 1 ≤ Li ≤ 50,000 ) 木板长度恰好等于各段木板长之和 Sample Input 3858 Sample Output 34 挑战上的一个奇妙的贪心的方法 #include <bits/stdc++.h> #define ll long long using namespace…
USACO 2006 November Gold Corn Fields 题目描述: Farmer John has purchased a lush new rectangular pasture composed of M by N square parcels. He wants to grow some yummy corn for the cows on a number of squares. Regrettably, some of the squares are infertil…
POJ 3253 Fence Repair STL堆操作 我想说,STL里堆是我目前见到最蛋疼的操作. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cstdlib> #include <cmath> #include <utility> #include <vector> #inc…
[题目链接] 点击打开链接 [算法] 状压DP [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 12 #define MOD 100000000 int M,N,i,j,k,ans,state; ][(<<)+],f[MAXN+][(<<)+],cnt[MAXN+],mat[MAXN+][MAXN+]; template <typename T> inline void read(…
题目大意: 输入n m 接下来n行m列 0表示不能种玉米 1表示能 要求种玉米位置的上下左右四连通区域不能种玉米 输出方案数 Sample Input 2 31 1 10 1 0 Sample Output 9 Hint Number the squares as follows: 1 2 3  4 There are four ways to plant only on one squares (1, 2, 3, or 4), three ways to plant on two square…
Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 77001   Accepted: 25185 Description Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000)…
版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/34805369 转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=3253" rel="nofollow">http://poj.org/problem?id=3253 Description Farmer John wants to repair a s…
Fence Repair Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3253 Appoint description:  hanjiangtao  (2014-11-12) System Crawler  (2015-04-24) Description Farmer John wants to repair a small len…
题意:农夫要将板割成n块,长度分别为L1,L2,...Ln.每次切断木板的花费为这块板的长度,问最小花费.21 分为 5 8 8三部分.   思路:思考将n部分进行n-1次两两合成最终合成L长度和题目所求花费一致.贪心,按木板长度排序,每次取长度最小的两块木板,则答案最小.因为合成次数是固定不变的,尽量让小的部分进行多次合成,这样总花费最小.   #include<cstdio> #include<queue> using namespace std; typedef long l…
题目大意:有N个站点的轻轨站,有一个容量为C的列车起点在1号站点,终点在N号站点,有K组牛群,每组数量为Mi(1≤Mi≤N),行程起点和终点分别为Si和Ei(1≤Si<Ei≤N).计算最多有多少头牛可以搭乘轻轨. 一道经典的贪心题目,每当一头牛上车的时候,如果超载,我们就优先踢出去行程终点比较远的那部分牛 而 踢出哪些行程终点较远的牛 以及 哪些在车上的牛在这站到达了终点,都可以用优先队列来维护,复杂度约为 贴上代码: #include <cstdio> #include <alg…