Skip to content

Commit eb99a83

Browse files
authored
Create 41_codechef_chef_and_glove.cpp
1 parent 9e580b9 commit eb99a83

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

41_codechef_chef_and_glove.cpp

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//
2+
// main.cpp
3+
// CODE-CHEF
4+
//
5+
// Created by Prince Kumar on 17/05/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// ---- ** CHEF AND GLOVE ** ------- //
9+
10+
11+
#include <iostream>
12+
using namespace std;
13+
int main()
14+
{
15+
int T; cin>>T;
16+
while(T--)
17+
{
18+
int n; cin>>n;
19+
// numbering 1 to n
20+
21+
int len[n+1]; // length of finger
22+
int glov [n+1]; // lenght of sheath
23+
24+
for(int i=1;i<n+1;i++)
25+
{
26+
cin>>len[i];
27+
}
28+
for(int i=1;i<n+1;i++)
29+
{
30+
cin>>glov[i];
31+
}
32+
33+
// front
34+
int front=0;
35+
for(int i=1;i<n+1;i++) // loop runs n times
36+
{
37+
if(len[i]<=glov[i])
38+
front++;
39+
}
40+
41+
// back
42+
int back=0;
43+
for(int i=1;i<n+1;i++)
44+
{
45+
if(len[i]<=glov[n+1-i]) // i=1 --> 8+1-1 = 8
46+
back++; // i=2 --> 8+1-2 =7
47+
}
48+
49+
if(front==n && back==n)
50+
{
51+
cout<<"both"<<endl;
52+
}
53+
else if(front!=n && back!=n )
54+
cout<<"none"<<endl;
55+
else if(front==n && back!=n)
56+
cout<<"front"<<endl;
57+
else if( front!=n && back ==n)
58+
cout<<"back"<<endl;
59+
}
60+
}
61+
62+
63+
64+
65+
66+
67+
68+

0 commit comments

Comments
 (0)