#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n+1];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
int g=1,ag=0;
bool alive = 1;
for(int i=0;i<n;i++)
{
if(g>a[i])
{
alive=0;
break;
}
else
{
ag+=1;
g+=1;
if(ag%6==0)
g+=1;
}
}
if(alive)
cout<<"Rick now go and save Carl and Judas\n";
else
{
cout<<"Goodbye Rick\n";
cout<<ag<<endl;
}
}
return 0;
}
#include <algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n+1];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
int g=1,ag=0;
bool alive = 1;
for(int i=0;i<n;i++)
{
if(g>a[i])
{
alive=0;
break;
}
else
{
ag+=1;
g+=1;
if(ag%6==0)
g+=1;
}
}
if(alive)
cout<<"Rick now go and save Carl and Judas\n";
else
{
cout<<"Goodbye Rick\n";
cout<<ag<<endl;
}
}
return 0;
}
No comments:
Post a Comment