forked from Prince-1501/Hello_world-Competiitve-Programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
41_codechef_chef_and_glove.cpp
68 lines (53 loc) · 1.26 KB
/
41_codechef_chef_and_glove.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// main.cpp
// CODE-CHEF
//
// Created by Prince Kumar on 17/05/19.
// Copyright © 2019 Prince Kumar. All rights reserved.
//
// ---- ** CHEF AND GLOVE ** ------- //
#include <iostream>
using namespace std;
int main()
{
int T; cin>>T;
while(T--)
{
int n; cin>>n;
// numbering 1 to n
int len[n+1]; // length of finger
int glov [n+1]; // lenght of sheath
for(int i=1;i<n+1;i++)
{
cin>>len[i];
}
for(int i=1;i<n+1;i++)
{
cin>>glov[i];
}
// front
int front=0;
for(int i=1;i<n+1;i++) // loop runs n times
{
if(len[i]<=glov[i])
front++;
}
// back
int back=0;
for(int i=1;i<n+1;i++)
{
if(len[i]<=glov[n+1-i]) // i=1 --> 8+1-1 = 8
back++; // i=2 --> 8+1-2 =7
}
if(front==n && back==n)
{
cout<<"both"<<endl;
}
else if(front!=n && back!=n )
cout<<"none"<<endl;
else if(front==n && back!=n)
cout<<"front"<<endl;
else if( front!=n && back ==n)
cout<<"back"<<endl;
}
}