Skip to content

Commit 5545367

Browse files
authored
Create 40_codechef_chef_judges_competition.cpp
1 parent d694eab commit 5545367

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// main.cpp
3+
// CODE-CHEF
4+
//
5+
// Created by Prince Kumar on 15/05/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// ---- ** chef judges a competition ** --- //
9+
10+
11+
#include <iostream>
12+
#include <algorithm>
13+
using namespace std;
14+
int main()
15+
{
16+
int T;cin>>T;
17+
while(T--)
18+
{
19+
int n; cin>>n;
20+
int a[n] ; // for ALICE
21+
int b[n] ; // for BOB
22+
23+
for(int i=0;i<n;i++)
24+
{
25+
cin>>a[i];
26+
}
27+
28+
for(int i=0;i<n;i++)
29+
{
30+
cin>>b[i];
31+
}
32+
33+
// sorting in ARRAY
34+
sort(a,a+n);
35+
sort(b,b+n);
36+
37+
int suma =0;
38+
int sumb = 0;
39+
40+
for(int i=0;i<n-1;i++)
41+
{
42+
suma = suma + a[i];
43+
sumb = sumb + b[i];
44+
}
45+
// we get sum results
46+
47+
if(suma==sumb)
48+
cout<<"Draw"<<endl;
49+
else if( suma < sumb)
50+
cout<<"Alice"<<endl;
51+
else
52+
cout<<"Bob"<<endl;
53+
54+
}
55+
}
56+
57+
58+
59+
60+
61+
62+

0 commit comments

Comments
 (0)