青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++天空

cpp_stu2's Land

re: 對一些DP題目的小結 姜雨生 2007-06-30 22:59
應該可以更加優化
re: 對一些DP題目的小結 姜雨生 2007-06-30 22:55
Margaritas on the River Walk
Time Limit:1000MS Memory Limit:65536K
Total Submit:309 Accepted:132

Description


One of the more popular activities in San Antonio is to enjoy margaritas in the park along the river know as the River Walk. Margaritas may be purchased at many establishments along the River Walk from fancy hotels to Joe’s Taco and Margarita stand. (The problem is not to find out how Joe got a liquor license. That involves Texas politics and thus is much too difficult for an ACM contest problem.) The prices of the margaritas vary depending on the amount and quality of the ingredients and the ambience of the establishment. You have allocated a certain amount of money to sampling different margaritas.

Given the price of a single margarita (including applicable taxes and gratuities) at each of the various establishments and the amount allocated to sampling the margaritas, find out how many different maximal combinations, choosing at most one margarita from each establishment, you can purchase. A valid combination must have a total price no more than the allocated amount and the unused amount (allocated amount – total price) must be less than the price of any establishment that was not selected. (Otherwise you could add that establishment to the combination.)

For example, suppose you have $25 to spend and the prices (whole dollar amounts) are:

Vendor A B C D H J
Price 8 9 8 7 16 5

Then possible combinations (with their prices) are:

ABC(25), ABD(24), ABJ(22), ACD(23), ACJ(21), ADJ( 20), AH(24), BCD(24), BCJ(22), BDJ(21), BH(25), CDJ(20), CH(24), DH(23) and HJ(21).

Thus the total number of combinations is 15.


Input


The input begins with a line containing an integer value specifying the number of datasets that follow, N (1 ≤ N ≤ 1000). Each dataset starts with a line containing two integer values V and D representing the number of vendors (1 ≤ V ≤ 30) and the dollar amount to spend (1 ≤ D ≤ 1000) respectively. The two values will be separated by one or more spaces. The remainder of each dataset consists of one or more lines, each containing one or more integer values representing the cost of a margarita for each vendor. There will be a total of V cost values specified. The cost of a margarita is always at least one (1). Input values will be chosen so the result will fit in a 32 bit unsigned integer.


Output


For each problem instance, the output will be a single line containing the dataset number, followed by a single space and then the number of combinations for that problem instance.


Sample Input


2
6 25
8 9 8 7 16 5
30 250
1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30

Sample Output


1 15
2 16509438

Hint


Note: Some solution methods for this problem may be exponential in the number of vendors. For these methods, the time limit may be exceeded on problem instances with a large number of vendors such as the second example below.


Source
Greater New York 2006
急需 我也要樓主 幫我傳一份吧
郵箱:cpp_student@163.com
謝謝!!!
re: 狀態壓縮DP, pku3020 姜雨生 2007-06-30 10:35
真是太好了
以后多向你請教
算你狠
我USACO全過了
你還在做A+B!
re: 凸包... 姜雨生 2007-06-30 10:26
#include<fstream>
#include<cstdlib>
using namespace std;
ifstream fin ("bag.in");
ofstream fout ("bag.out");
struct xys
{
int x;
int y;
};
int N;//數目
xys xy[101];//坐標系
int top;//堆棧頂
int stk[101];//堆棧
void swap(xys *a,xys *b)
{
xys tmp = *a;
*a = *b;
*b =tmp;
}
int multi(xys a,xys b,xys c)
{
return (a.x-c.x)*(b.y-c.y)-(b.x-c.x)*(a.y-c.y);//求叉積
}
bool comp(xys p1,xys p2)
{
int t;
t=multi(p1,p2,xy[0]);
if ((t>=0)&&((p1.x-xy[0].x)+(p1.y-xy[0].y)<(p2.x-xy[0].x)+(p2.y-xy[0].y)))
return true;//叉積正確
return false;
}
void sort(int p,int r)
{
int i,j;
xys x;
if (r-p+1<=5)
{
for (j=p+1;j<=r;j++)
{
i=j;
while(i>1&&comp(xy[i],xy[i-1]))
{
swap(&xy[i],&xy[i-1]);//交換元素
i--;
}
}
}
else
{
x=xy[p+rand()%(r-p+1)];//隨即選區一個支點
i=p,j=r;
do
{
while (comp(xy[i],x))i++;
while (comp(x,xy[j]))j--;
if (i<j)swap(&xy[i],&xy[j]);
}//一次規劃
while (i<j);
sort(p,j);//前半部
sort(p+1,r);//后半部
}
}
void init()
{
int i;
fin>>N;
for(i=0;i<N;i++){
fin>>xy[i].x>>xy[i].y;
if (xy[i].y<=xy[0].y&&xy[i].x<xy[0].y) swap(xy[0],xy[i]);//交換
}
sort(1,N-1);
}
void graham()
{
int i;
for(i=1;i<=3;i++) stk[i]=i-1;
top=3;
for(i=3;i<N;i++)
{
while(multi(xy[i],xy[stk[top]],xy[stk[top-1]])>=0) top--;//所有未向左傳的點去掉
top++;
stk[top]=i;//入棧
}
for (i=1;i<=top;i++)
fout<<xy[stk[i]].x<<" "<<xy[stk[i]].y<<endl;
}
int main (void)
{
init();
graham();//掃描出凸包,打印
return 0;
}
<2025年12月>
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910

導航

統計

常用鏈接

留言簿(1)

隨筆檔案

文章檔案

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美r片在线| 亚洲精品乱码久久久久久久久 | 久久精品一二三区| 国内精品一区二区三区| 久久综合五月| 美女啪啪无遮挡免费久久网站| 亚洲国产欧美一区| 亚洲国产欧美精品| 欧美肉体xxxx裸体137大胆| 亚洲综合日韩中文字幕v在线| a91a精品视频在线观看| 国产免费成人在线视频| 久久中文精品| 欧美精品福利在线| 性欧美大战久久久久久久免费观看| 亚洲中字在线| 亚洲精品1区2区| 99日韩精品| 狠狠色综合网站久久久久久久| 免费在线观看精品| 国产精品theporn| 久久夜色撩人精品| 欧美日韩国产小视频| 欧美在线观看www| 蜜桃久久精品乱码一区二区| 在线中文字幕日韩| 久久久久一区| 中文网丁香综合网| 久久久久久久久伊人| 亚洲一区二区三区中文字幕| 欧美伊久线香蕉线新在线| 日韩图片一区| 久久精品男女| 亚洲自拍偷拍麻豆| 欧美成人蜜桃| 久久久久www| 欧美日韩一区二区三区免费看| 久久久国产精品一区二区三区| 欧美经典一区二区| 久久婷婷麻豆| 国产精品午夜在线观看| 91久久嫩草影院一区二区| 国产日韩综合一区二区性色av| 亚洲黑丝在线| 亚洲国产精品一区二区久| 亚洲一区二区三区影院| 99精品热6080yy久久| 久久久亚洲欧洲日产国码αv| 亚洲一区二区黄| 欧美另类专区| 欧美激情视频一区二区三区不卡| 国产精品午夜国产小视频| 亚洲区中文字幕| 欲色影视综合吧| 久久精品国产综合精品| 欧美一级淫片aaaaaaa视频| 欧美精品日韩一区| 91久久久久久| 亚洲精品永久免费| 蜜臀99久久精品久久久久久软件| 久久伊人一区二区| 国产在线日韩| 久久精品国产99国产精品| 久久九九99| 国产亚洲亚洲| 欧美一区在线视频| 老司机久久99久久精品播放免费| 国产免费成人在线视频| 一区二区三欧美| 亚洲尤物在线| 国产日韩精品久久| 欧美中文字幕在线| 久久这里有精品15一区二区三区| 国产综合网站| 久久婷婷成人综合色| 欧美成人一区二免费视频软件| 在线播放豆国产99亚洲| 久久夜色精品国产| 亚洲国产精品成人精品| 日韩视频在线一区二区| 欧美日韩亚洲一区二区| 一区二区精品在线观看| 午夜精品视频在线观看一区二区| 国产日韩欧美二区| 久久久久久欧美| 亚洲国产精品va在看黑人| 99riav久久精品riav| 国产精品久久久久国产精品日日 | 久久久亚洲成人| 伊人久久噜噜噜躁狠狠躁| 免费影视亚洲| 亚洲图片欧美日产| 久久精品国产综合精品| …久久精品99久久香蕉国产| 欧美激情一区二区三区不卡| 一区二区三区免费网站| 浪潮色综合久久天堂| 日韩亚洲欧美中文三级| 国产精品一区亚洲| 久久免费视频在线观看| 亚洲国产成人在线视频| 午夜宅男久久久| 91久久精品国产91久久性色tv| 欧美激情国产日韩精品一区18| 亚洲无线视频| 女女同性精品视频| 亚洲一区久久| 91久久久亚洲精品| 国产日韩一区二区三区在线播放| 免费观看一区| 午夜精品理论片| 亚洲日本aⅴ片在线观看香蕉| 午夜亚洲性色福利视频| 亚洲日本va午夜在线电影| 国产精品欧美日韩一区| 六月丁香综合| 欧美一区二区成人6969| 亚洲美女av在线播放| 久久一区二区三区国产精品 | 亚洲日本乱码在线观看| 国产伦精品一区| 欧美另类视频| 老鸭窝亚洲一区二区三区| 亚洲在线播放| 中日韩美女免费视频网址在线观看 | 日韩一本二本av| 好看的亚洲午夜视频在线| 欧美午夜片欧美片在线观看| 美女在线一区二区| 久久婷婷国产麻豆91天堂| 欧美亚洲在线| 国产精品99久久不卡二区| 最新国产成人在线观看| 欧美~级网站不卡| 久久久久久久久久久久久女国产乱 | 奶水喷射视频一区| 久久久成人精品| 欧美一区二区视频免费观看| 亚洲一区二区三区乱码aⅴ| 99国产麻豆精品| 一区二区av在线| 99精品免费网| 一区二区不卡在线视频 午夜欧美不卡' | 狠狠入ady亚洲精品经典电影| 国产精品亚洲精品| 国产精品久久久久久久久免费桃花| 欧美另类综合| 欧美日韩一区在线观看视频| 欧美日韩免费精品| 欧美视频精品一区| 国产精品久久久久久久app| 国产精品久久久久久亚洲毛片| 欧美区在线播放| 国产精品爱啪在线线免费观看| 欧美日韩精品一区二区在线播放| 欧美国产精品劲爆| 欧美日本韩国| 国产精品免费观看在线| 国产欧美日韩精品一区 | 免费影视亚洲| 欧美理论电影网| 欧美视频日韩视频在线观看| 国产精品成人午夜| 国产精品一区在线播放| 韩国成人精品a∨在线观看| 亚洲福利国产| 亚洲视频网在线直播| 香蕉久久夜色精品国产使用方法| 欧美在线观看一二区| 男人的天堂亚洲| 亚洲精品美女| 亚洲欧美视频在线| 麻豆精品一区二区综合av| 欧美日本在线播放| 国产精品亚发布| 亚洲精品1区2区| 午夜精品久久久久久| 美女视频网站黄色亚洲| 亚洲精品日韩一| 久久国产精品一区二区| 欧美极品欧美精品欧美视频| 国产精品国产三级欧美二区| 尤物网精品视频| 亚洲免费视频中文字幕| 嫩草国产精品入口| 中文在线一区| 免费欧美在线| 国产欧美一区二区精品性| 日韩视频免费| 久久久久久一区| 日韩一级免费| 久热综合在线亚洲精品| 国产精品剧情在线亚洲| 亚洲黄色天堂| 久久精品夜色噜噜亚洲a∨ | 久久爱www久久做| 亚洲精品小视频| 久久久久久久一区二区三区| 国产精品久久波多野结衣| 在线色欧美三级视频|