## End Sorted solution codechef

End Sorted solution codechef Chef considers a permutation PP of {1,2,3,…,N}{1,2,3,…,N} End Sorted if and only if P1=1P1=1 and PN=NPN=N. Chef is given a permutation PP. In one operation Chef can choose any index i (1≤i≤N−1)i (1≤i≤N−1) and swap PiPi and Pi+1Pi+1. Determine the minimum number of operations required by Chef to make the permutation PP End Sorted. Note: An array PP is said to be a permutation of {1,2,3,…,N}{1,2,3,…,N} if PP contains each element of {1,2,3,…,N}{1,2,3,…,N} exactly once. Input Format The …

## Construct N solution codechef

Construct N solution codechef You are given an integer NN. Find if it is possible to represent NN as the sum of several(possibly zero) 22‘s and several(possibly zero) 77‘s. Formally, find if there exist two integers X,Y (X,Y≥0)X,Y (X,Y≥0) such that 2⋅X+7⋅Y=N2⋅X+7⋅Y=N. Input Format The first line of input will contain a single integer TT, denoting the number of test cases. Each test case consists of …

## Minimum Coins solution codechef

Minimum Coins solution codechef There are only 22 type of denominations in Chefland: Coins worth 11 rupee each Notes worth 1010 rupees each Chef wants to pay his friend exactly XX rupees. What is the minimum number of coins Chef needs to pay exactly XX rupees? Input Format The first line of input will contain a single integer TT, denoting the number of test cases. Each test case …

## Chess Time solution codechef

Chef has recently started playing chess, and wants to play as many games as possible. He calculated that playing one game of chess takes at least 2020 minutes of his time. Chef has NN hours of free time. What is the maximum number of complete chess games he can play in that time? Chess Time solution codechef The first line of input …

## chef on date solution codechef

Chef and his girlfriend go on a date. Chef took XX dollars with him, and was quite sure that this would be enough to pay the bill. At the end, the waiter brought a bill of YY dollars. Print “YES” if Chef has enough money to pay the bill, or “NO” if he has to borrow from his girlfriend and leave a bad …

## Good Key, Bad Key solution codeforces

There are n chests. The i-th chest contains ai coins. You need to open all n chests in order from chest 11 to chest n. Solution – CLICK HERE Good Key, Bad Key solution codeforces There are two types of keys you can use to open a chest: a good key, which costs k coins to use; a bad key, which does not cost any coins, but will halve …

## Yet Another Problem About Pairs Satisfying an Inequality solution codeforces

You are given an array 1,2,…a1,a2,…an. Count the number of pairs of indices 1≤,≤1≤i,j≤n such that <<<ai<i<aj<j. Solution – CLICK HERE Yet Another Problem About Pairs Satisfying an Inequality solution codeforces The first line contains an integer t (1≤≤10001≤t≤1000) — the number of test cases. The first line of each test case contains an integer n (2≤≤2⋅1052≤n≤2⋅105) — the length of the array. The second line …

## Mirror Grid solution codeforces

You are given a square grid with n rows and n columns. Each cell contains either 00 or 11. Solution – CLICK HERE Mirror Grid solution codeforces In an operation, you can select a cell of the grid and flip it (from 0→10→1 or 1→01→0). Find the minimum number of operations you need to obtain a square that remains the same when rotated 0∘0∘, 90∘90∘, 180∘180∘ and 270∘270∘. The picture below …

## Double Strings solution codeforces

You are given n strings 1,2,…,s1,s2,…,sn of length at most 88. Solution – CLICK HERE For each string si, determine if there exist two strings sj and sk such that =+si=sj+sk. That is, si is the concatenation of sj and sk. Note that j can be equal to k. Double Strings solution codeforces Recall that the concatenation of strings s and t is +=12…12…s+t=s1s2…spt1t2…tq, where p and q are the lengths of strings s and t respectively. For example, concatenation of “code” and “forces” is “codeforces“. Input The first …

## Cypher solution codeforces

Luca has a cypher made up of a sequence of n wheels, each with a digit ai written on it. On the i-th wheel, he made bi moves. Each move is one of two types: Solution – CLICK HERE up move (denoted by U): it increases the i-th digit by 11. After applying the up move on 99, it becomes 00. down move (denoted by D): it decreases the i-th digit by 11. …