Skip to content

Commit 0653442

Browse files
Merge pull request #177 from Sitzz23/Sitanshu
added solution
2 parents b958ee2 + 16ee10d commit 0653442

File tree

4 files changed

+144
-0
lines changed

4 files changed

+144
-0
lines changed

Codechef Solutions/c/olyrank

48.8 KB
Binary file not shown.

Codechef Solutions/c/olyrank.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// In Olympics, the countries are ranked by the total number of medals won. You are given six integers G1
2+
// , S1
3+
// , B1
4+
// , and G2
5+
// , S2
6+
// , B2
7+
// , the number of gold, silver and bronze medals won by two different countries respectively. Determine which country is ranked better on the leaderboard. It is guaranteed that there will not be a tie between the two countries.
8+
9+
// Input Format
10+
// The first line of the input contains a single integer T
11+
// denoting the number of test cases. The description of T
12+
// test cases follows.
13+
14+
// The first and only line of each test case contains six space-separated integers G1
15+
// , S1
16+
// , B1
17+
// , and G2
18+
// , S2
19+
// , B2
20+
// .
21+
22+
// Output Format
23+
// For each test case, print "1" if the first country is ranked better or "2" otherwise. Output the answer without quotes.
24+
25+
// Constraints
26+
// 1≤T≤1000
27+
// 0≤G1,S1,B1,G2,S2,B2≤30
28+
// Subtasks
29+
// Subtask #1 (100 points): Original constraints
30+
31+
// Sample Input 1
32+
// 3
33+
// 10 20 30 0 29 30
34+
// 0 0 0 0 0 1
35+
// 1 1 1 0 0 0
36+
// Sample Output 1
37+
// 1
38+
// 2
39+
// 1
40+
// Explanation
41+
// Test case 1
42+
// : Total medals for the first country are 10+20+30=60
43+
// and that for the second country are 0+29+30=59
44+
// . So the first country is ranked better than the second country.
45+
46+
// Test case 2
47+
// : Total medals for the first country are 0+0+0=0
48+
// and that for the second country are 0+0+1=1
49+
// . So the second country is ranked better than the first country.
50+
51+
//SOLUTION -->
52+
53+
#include <stdio.h>
54+
55+
int main(void) {
56+
57+
int t;
58+
scanf("%d",&t);
59+
while(t>0){
60+
int g1, s1, b1, g2, s2, b2;
61+
scanf("%d %d %d %d %d %d",&g1,&s1,&b1,&g2,&s2,&b2);
62+
if((g1+s1+b1)>(g2+s2+b2)){
63+
printf("1\n");
64+
}
65+
else
66+
printf("2\n");
67+
t--;
68+
}
69+
return 0;
70+
}
71+

Codechef Solutions/c/probdiff

49 KB
Binary file not shown.

Codechef Solutions/c/probdiff.c

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// You have prepared four problems. The difficulty levels of the problems are A1,A2,A3,A4
2+
// respectively. A problem set comprises at least two problems and no two problems in a problem set should have the same difficulty level. A problem can belong to at most one problem set. Find the maximum number of problem sets you can create using the four problems.
3+
4+
// Input Format
5+
// The first line of the input contains a single integer T
6+
// denoting the number of test cases. The description of T
7+
// test cases follows.
8+
// The first and only line of each test case contains four space-separated integers A1
9+
// , A2
10+
// , A3
11+
// , A4
12+
// , denoting the difficulty level of four problems.
13+
// Output Format
14+
// For each test case, print a single line containing one integer - the maximum number of problem sets you can create using the four problems.
15+
16+
// Constraints
17+
// 1≤T≤1000
18+
// 1≤A1,A2,A3,A4≤10
19+
// Subtasks
20+
// Subtask #1 (100 points): Original constraints
21+
22+
// Sample Input 1
23+
// 3
24+
// 1 4 3 2
25+
// 4 5 5 5
26+
// 2 2 2 2
27+
// Sample Output 1
28+
// 2
29+
// 1
30+
// 0
31+
// Explanation
32+
// Test case 1
33+
// : You can prepare the first problem set using the first two problems and the second problem set using the next two problems. So the problem sets will be [1,4]
34+
// and [3,2]
35+
// .
36+
37+
// Test case 2
38+
// : You can prepare one problem set using one problem having a difficulty level of 4
39+
// and the other having a difficulty level of 5
40+
// . There is no way to prepare more than one problem set.
41+
42+
// Test case 3
43+
// : There is no way to prepare a problem set.
44+
45+
//SOLUTION -->
46+
47+
#include <stdio.h>
48+
49+
int main(void) {
50+
51+
int t;
52+
scanf("%d",&t);
53+
while(t>0){
54+
int arr[4],i,j,count=0;
55+
for(i=0;i<4;i++){
56+
scanf("%d",&arr[i]);
57+
}
58+
for(i=0;i<4;i++){
59+
for(j=0;j<4;j++){
60+
(arr[i]==arr[j])?(count+=1):(count+=0);
61+
}
62+
}
63+
if(count==4)
64+
printf("2\n");
65+
else if(count==10)
66+
printf("1\n");
67+
else if(count==16)
68+
printf("0\n");
69+
else printf("2\n");
70+
t--;
71+
}
72+
return 0;
73+
}

0 commit comments

Comments
 (0)