栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 2297 Survival

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 2297 Survival

#include <cstdio>#include <cstring>#include <string>#include <iostream>#include <algorithm>#include <vector>using namespace std;const long long N = 22;const int inf = 0x3f3f3f3f;int dp[1<<N];pair<int,int> p[N];int main(){    int n,boss;    while(~scanf("%d",&n) && n)    {        n--;        for(int i=0;i<n;i++)        { int x,y; scanf("%d%d",&x,&y); p[i]=make_pair(x,y);        }        scanf("%d",&boss);        memset(dp,0,sizeof(dp));        int ans = 0;        dp[0]=100;        for(int st=1;st<(1<<n);st++)        { dp[st]=-inf;   for(int j=0;j<n;j++)     if(st&(1<<j)&&dp[st&~(1<<j)]>=p[j].first)     {         dp[st]=max(dp[st],dp[st&~(1<<j)]-p[j].first+p[j].second);         if(dp[st]>100)  dp[st]=100;     }        }        if(dp[(1<<n)-1]>=boss) puts("clear!!!");        else puts("try again");    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/380058.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号