A tough TCS Codevita 2020?

Mine as well.

I think this solution will also got accepted for minimize the sum

code

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
fastio;
ll n,s=0,i,k;
cin>>n>>k;
ll a[n];
for(i=0;i<n;i++)
cin>>a[i];

sort(a,a+n,greater<int>());
 i=0;
while(k--)
{
    if(a[i]>a[i+1])
    a[i]=a[i]/2;
    else
    {
        i++;
        a[i]=a[i]/2;
    }
}
for(i=0;i<n;i++)
s+=a[i];
cout<<s<<endl;

}

Do any of you know how many question sto solve for qualifying for second round

Do you have correct solution for the problem Hedger then it would be very kind of you if you share it.

Guys wanting questions can visit here

1 Like

As i said Hedger showed MLE when using efficient approach probably because range of W was in 10^6 if you would like to know then go through problem after reading 01 knapsack.

Can you share your MLE code? What I thought was the problem was variation of unbounded knapsack where the catch is we can take fixed K amount of any item and not infinite number of any item.Correct me if I am wrong.

Yes, we can take any stock depending on the profit it generates for <=K times such that our total cost doesn’t exceeds total amount we have that is W.I am not sure of credibility as i just passed sample cases but it may help you.
Take the code for reference:

def knapSack(W, wt, val, n):
K = [[0 for x in range(W + 1)] for x in range(n + 1)]

# Build table K[][] in bottom up manner
for i in range(n + 1):
    for w in range(W + 1):
        if i == 0 or w == 0:
            K[i][w] = 0
        elif wt[i - 1] <= w:
            K[i][w] = max(val[i - 1]
                          + K[i - 1][w - wt[i - 1]], K[i - 1][w])
        else:
            K[i][w] = K[i - 1][w]

return K[n][W]

tCases = int(input())
for _ in range(tCases):
n1, k1, W1 = map(int, input().split())
wt1 = list(map(int, input().split()))
profit = list(map(int, input().split()))
newWt = []
newVal = []
val1 = []
for i in range(n1):
tempVal = wt1[i]*profit[i]/100
val1.append(tempVal) #Profit list is made
for i in range(n1):
for j in range(k1):
newWt.append(wt1[i])
newVal.append(val1[i]) #append each value weight and profit K times
n1 *= k1
print(round(knapSack(W1, newWt, newVal, n1)))

1 Like
  1. code kart
  2. signal connection
  3. best sequence
  4. lift
  5. engagement ring
  6. hedger
    solved None…

can anyone please make me understand faulty keyboard question ?
I am confused with the given test cases .
| denotes cursor position-
my thought : T= empower , S=ew then , for me minimum operations will be : e|w (p+m)-> empow|(m)->empowe|(p+b)-> empower| ,
so total operations will be 5 , am i doing anything wrong ?

You are right from your logic, but i guess they want it for each time you write e or w you have to perform paste which is not optimized, moreover i am not sure,you may be right in this but failing in other test cases.

Did questions repeat from 8th evening in 9th morning during Codevita?

How much time was remaining when you took this screenshot?

Less than 3½ hours

1 Like

if you have seen the question i think they are considering each word independently.

Does anyone know the logic behind the question Engagement Ring? Thanks.

can anyone have the solution of Tank problem in codevita 2020 ?

Do anyone have the solution of faulty keyboard preferably in python , other languages will also help, PLEASE SHARE!

in the question MAXIMUM PRIZES , is it necessary that opponent order will be in ascending order?

has anyone solved travel cost , if yes please share the logic and code if possible