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

poj 2709 Painter

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

poj 2709 Painter

#include<stdio.h>#include<stdlib.h>#include<queue>using namespace std;int N;int amount[15];int mix;int main(){    while(scanf("%d",&N)!=EOF&&N){       int Max=-1;       for(int i=1;i<=N;i++){scanf("%d",&amount[i]);if(Max<amount[i])    Max=amount[i];       }       scanf("%d",&mix);       int nf;       if(Max%50==0){nf=Max/50;       }else{nf=Max/50+1;}       int i;       if(mix==0){printf("%dn",nf);       }       else{ priority_queue<int> q; int tt=mix;  while((i=nf++)>=0){    mix=tt;    while(!q.empty())        q.pop();    int v=i*50;    for(int j=1;j<=N;j++){        int tmpa=v-amount[j];        if(tmpa>0){ q.push(tmpa);        }    }    bool flag=false;    while(q.size()>=3){ int a=q.top();q.pop(); int b=q.top();q.pop(); int c=q.top();q.pop(); --a;--b;--c;--mix; if(mix==0){     flag=true;     break; } if(a>0)     q.push(a); if(b>0)     q.push(b); if(c>0)     q.push(c);    }    if(flag)        break;          }          printf("%dn",i);       }    }    return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/378208.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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