UVA - 12108 Extraordinarily Tired Students

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_42623428/article/details/82986939
#include <bits/stdc++.h>

using namespace std;
#define N 100010
int main()
{
    int x[14],y[14],z[14];
    int n,t,f=0;
    while(cin>>n&&n)
    {
        for(int i=0; i<n; i++)
        {
            cin>>x[i]>>y[i]>>z[i];
        }
        int t;
        int cnt;
        for(t=1; t<N; t++)
        {
            cnt=0;
            for(int i=0; i<n; i++)
            {
                if(z[i]<=x[i])
                    cnt++;
            }
            if(cnt==n)break;
            for(int i=0; i<n; i++)
            {
                if(z[i]==x[i]+y[i]||(z[i]==x[i]&&cnt>=n-cnt))
                    z[i]=0;
                z[i]++;
            }
        }
        if(t==N)t=-1;
        cout<<"Case "<<++f<<": "<<t<<endl;
    }
}

猜你喜欢

转载自blog.csdn.net/qq_42623428/article/details/82986939
今日推荐