超时

#include<bits/stdc++.h>
using namespace std;
int c[1010],w[1010][8];
int main(){
    int n,e;
    while(~scanf("%d%d",&n,&e)){
        memset(w,0,sizeof(w));
        int flag=0;
        for(int i=0;i<n;i++){
            int m;
            scanf("%d%d",&c[i],&m);
            flag+=c[i];
            while(m--){
                int a;
                scanf("%d",&a);
                w[i][a]=1;
            }
        }
        int cnt=0,d=1;
        while(flag){
            int num=0,i=0;
            while(num<e){
                if(w[i][d]&&c[i]){
                    c[i]--;
                    num++;
                    flag--;
                }
                i++;
                if(i==n)
                    i=0;
            }
            d++;
            if(d==8)
                d=1;
            cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}
双while肯定超,我就是想模拟一下过程。
然后,写完之后,反而被思路禁锢了,然后不知道从哪下手减少时间。。。。。。
全部评论
关键是你这双while贪心也不一定对啊...
点赞 回复 分享
发布于 2020-04-19 16:30

相关推荐

不愿透露姓名的神秘牛友
昨天 15:58
点赞 评论 收藏
分享
07-07 11:33
江南大学 Java
已经在暑假实习了&nbsp;,没有明确说有hc,纠结实习到八月份会不会有点影响秋招毕竟感觉今年好多提前批
程序员小白条:92的话准备提前批,其他没必要,没面试机会的,而且你要准备充分,尤其八股和算法题
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务