1.
Chef in Vaccination Queue
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int[] token_2 = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int count = 0;
for(int j = 0; j < token[1]; j++){
if(token_2[j] == 0){
count += token[2];
}
else if(token_2[j] == 1){
count += token[3];
}
}
Console.WriteLine(count);
}
2. Candies
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int n = int.Parse(Console.ReadLine());
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
Array.Sort(token);
bool a = true;
for(int j = 0; j < 2*n - 2; j++){
if(token[j] == token[j+1] && token[j+1] == token[j+2]) a = false;
}
if(a) Console.WriteLine("Yes");
else Console.WriteLine("No");
}
3. Packaging Cupcakes
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int n = int.Parse(Console.ReadLine());
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int a = ((int) n / 2) + 1;
Console.WriteLine(a);
}
4. Chef Diet
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int[] token1 = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int money = 0;
int c = 0;
for(int j = 0; j < token[0]; j++){
money += (token1[j] - token[1]);
if(money < 0){
c = j + 1;
break;
}
}
if(c == 0){
Console.WriteLine("YES");
} else{
Console.WriteLine("NO "+c);
}
}
5. Break the Stick
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
if(token[0] % 2 == 0) Console.WriteLine("YES");
else if(token[1] % 2 == 0) Console.WriteLine("NO");
else Console.WriteLine("YES");
}
6. Encoding Message
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
//int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int num = int.Parse(Console.ReadLine());
string str = Console.ReadLine();
for(int j = 0; j < num; j += 2){
if(j + 1 < num){
Console.Write((char)('z' - str[j + 1] + 'a'));
}
Console.Write((char)('z' - str[j] + 'a'));
}
Console.WriteLine();
}
7. Bear and Candies 123
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
for(int j = 1; token[0] >= 0 && token[1] >= 0; j++){
if(j % 2 == 1){
token[0] -= j;
} else
{
token[1] -= j;
}
}
if(token[0] < 0) Console.WriteLine("Bob");
else if(token[1] < 0) Console.WriteLine("Limak");
}
8. Elections in Chefland
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
if(token[0] > 50) Console.WriteLine("A");
else if(token[1] > 50) Console.WriteLine("B");
else if(token[2] > 50) Console.WriteLine("C");
else Console.WriteLine("NOTA");
}
9. Chef and Two Strings
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int min = 0, max = 0;
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
for(int j = 0; j < s1.Length; j++){
if(s1[j] == '?' || s2[j] == '?') max++;
else if(s1[j] != s2[j]){
min++;
max++;
}
}
Console.WriteLine(min + " " + max);
}
10. Buying New Tablet
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int choice = 0;
for(int j = 0; j < token[0]; j++){
int temp = choice;
int[] token2 = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int mul = token2[0] * token2[1];
if(token[1] >= token2[2]){
if(!(choice > mul)){
choice = mul;
}
else{
choice = choice;
}
}
}
if(choice == 0){
Console.WriteLine("no tablet");
} else Console.WriteLine(choice);
}
11. Card Removal
static int findDup(int[] arr, int num){
int dup = 0;
for(int i = 0; i < arr.Length; i++){
if(arr[i] == num) dup++;
}
return dup;
}
static void Main(string[] args){
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int num = int.Parse(Console.ReadLine());
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int max = 0;
for(int j = 0; j < num; j++){
int temp = findDup(token, token[j]);
if(max < temp) max = temp;
}
Console.WriteLine(num - max);
}
}
12. Even-tual Reduction
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int num = int.Parse(Console.ReadLine());
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
string str = Console.ReadLine();
bool isHave = true;
for(int j = 0; j < str.Length; j++){
if(!((str.Split(str[j]).Length - 1) % 2 == 0)){
isHave = false;
break;
}
}
Console.WriteLine(isHave ? "YES" : "NO");
}
13. Chef and Subarrays
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int num = int.Parse(Console.ReadLine());
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int total = 0;
for(int j = 0; j < num; j++){
int sum = 0, pro = 1;
for(int k = j; k < num; k++){
sum += token[k];
pro *= token[k];
if(sum == pro) total++;
}
}
Console.WriteLine(total);
}
14. Airline Restrictions
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
if((token[0] <= token[4] && token[1] + token[2] <= token[3]) ||
(token[1] <= token[4] && token[0] + token[2] <= token[3]) || (token[2] <= token[4]
&& token[0] + token[1] <= token[3])){
Console.WriteLine("YES");
}
else Console.WriteLine("NO");
}
15. Zero String
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int num = int.Parse(Console.ReadLine());
string bin = Console.ReadLine();
int count = 0;
for(int j = 0; j < num; j++){
if(bin[j] == '0'){
count++;
}
}
Console.WriteLine(count < (num - count) ? count + 1 : num - count);
}
16. Odd Pairs
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
long num = long.Parse(Console.ReadLine());
Console.WriteLine((num*num)/2);
}
17. Efficient PAN Linking
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
// int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
string str = Console.ReadLine();
int num = 0;
for(int j = 0; j < str.Length; j++){
num = (num * 10 + (str[j] - '0'))%20;
}
Console.WriteLine(num);
}
18.Weight Balance
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int min = (token[2] < token[3]) ? token[2] * token[4] : token[3] *
token[4];
int max = (token[2] > token[3]) ? token[2] * token[4] : token[3] *
token[4];
int increase = token[1] - token[0];
if(increase >= min && increase <= max) Console.WriteLine(1);
else Console.WriteLine(0);
}
19. Cutting Recipes
int testCase = Convert.ToInt32(Console.ReadLine());
for(int i = 0; i < testCase; i++){
int[] token = Array.ConvertAll(Console.ReadLine().Split(' '),
int.Parse);
int num = token[0];
int gdcnum = token[1];
for(int j = 1; j <= num; j++){
gdcnum = gcd(gdcnum, token[j]);
}
for(int j = 1; j <= num; j++){
token[j] = token[j] / gdcnum;
}
for(int j = 1; j <= num; j++){
Console.Write(token[j] + " ");
}
Console.WriteLine();
}