Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions codechef/NOV18/nov chef1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long t;
cin>>t;
while(t--){
long long a,b;
cin>>a>>b;
cout<<"YES"<<endl;
}
}

35 changes: 35 additions & 0 deletions codechef/NOV18/nov chef2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<bits/stdc++.h>
#define lli long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int mod=1e9+7;
int main()
{
fast;
lli t;
cin>>t;
while(t--){
lli n;
cin>>n;
lli arr[n+1],c[n+1]={0},i,j;
bool b[n+1]={false};
for(i=0;i<n;i++)
cin>>arr[i],b[arr[i]]=true;

for(i=0;i<n;i++){
if(b[i+1])
c[arr[i]]++;
}
i=0;
for(i=1;i<=n;i++){
if(c[i]>=2){
cout<<"Truly Happy\n";
break;
}

if(i>n)
cout<<"Poor Chef"<<endl;

}
}}

22 changes: 22 additions & 0 deletions codechef/NOV18/nov chef3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<stdio.h>
#include<math.h>
int main()
{
// jacobsthal number
int a[25] = {1,1,3,5,11,
21,43,85,171,341,
683,1365,2731,5461,10923,
21845,43691,87381,174763,349525,
699051,1398101,2796203,5592405,11184811};

int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
int y;
y = pow(2,n);
printf("%d %d ",a[n-1],y);
}
}
100 changes: 100 additions & 0 deletions codechef/NOV18/nov chef4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
fast;
long int n,k,q,i,j,c_1,c_2,c_3,c_4,l,m,r,s,o,z,t;
int y,a;
cin>>n>>q>>k;
deque<int> v;
char c;
o=c_1=c_2=c_3=c_4=0;
for(i=0;i<n;i++)
{ cin>>a;
v.push_back(a);
if(a==0)
o=0;

else
{
++o;
if(o>c_1)
{
c_1=o;
m=i;
l=i-c_1+1;
if(l==0)
{
c_2=c_1;
}
}
else if(o>=c_4)
{
c_4=o;
s=i;
}
if(i==n-1)
{c_3=o;}
}
}

z=0;
for(j=0;j<q;j++)
{ cin>>c;
if(c=='!')
{
if(m==n-1)
{ c_1=c_1-1;
if(c_3==0)
{c_3=c_1;
c_2=1;
z=1;
}
if(c_4>c_1)
{ t=c_1;
c_1=c_4;
c_4=t;
++s;
m=s;
}

}
else
{ ++m;
++s;
}
if(c_3>0)
{if(z==1)
{z=0;}
else
{
--c_3;
++c_2;
}
if(c_2>c_1)
{
c_1=c_2;
m=c_1-1;
}
else if(c_2>=c_4)
{
c_4=c_2;
s=c_2-1;
}
}

}


else if(c=='?')
{
if(c_1>=k)
cout<<k<<"\n";
else
cout<<c_1<<"\n";
}
}

return 0;
}