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

zoj 1161 Gone Fishing

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

zoj 1161 Gone Fishing

#include<stdio.h>void block(){ int i,j,k,g,n,h,ans,tot,f[32],d[32],t[32],now[32]; scanf("%d",&n); while (n) {  scanf("%d",&h);  h=h*12;  for(i=0;i<n;i++)  {   scanf("%d",&f[i]);   now[i]=f[i];  }  for(i=0;i<n;i++)   scanf("%d",&d[i]);  for(i=0;i<n-1;i++)   scanf("%d",&t[i]);  int times[32]={0};  ans=0;  for(i=0;i<n&&h>0;i++)  {   for(j=0;j<i;j++)    now[j]=f[j];   int tnow[32]={0};tot=0;   for(k=0;k<h;k++)   {       g=0;    for(j=1;j<=i;j++)     if(now[j]>now[g])      g=j;    tot=tot+now[g];    now[g]=now[g]-d[g];    if(now[g]<0)     now[g]=0;    tnow[g]++;   }   if(tot>ans)   {    ans=tot;    for(j=0;j<n;j++)     times[j]=tnow[j];   }   else if(tot==ans)   {    for(j=0;j<n;j++)     if(tnow[j]!=times[j])      break;    if(j<n&&tnow[j]>times[j])     for(g=j;g<n;g++)      times[g]=tnow[g];   }   h=h-t[i];  }  for(i=0;i<n-1;i++)   printf("%d, ",times[i]*5);  printf("%dnNumber of fish expected: %dn",times[n-1]*5,ans);  scanf("%d",&n);  if(n)   printf("n"); }}int main(){ int i,N; scanf("%d",&N); for(i=0;i<N;i++) { block(); if(i!=N-1)  printf("n"); } return 0;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/374073.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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