Codechef Starters 141 | Video Solutions - A to D | by Abhinav Kumar | TLE Eliminators
ฝัง
- เผยแพร่เมื่อ 10 ก.ค. 2024
- Here are the video solutions in the form of a post-contest discussion for problems A, B, C, D of Codechef Starters 141 (Div 2). The live discussion was done with students of TLE Eliminators, this is the recording of the same. We hope this will be useful for you in up-solving this contest.
📢Check out handpicked problems by Priyansh himself, on our CP-31 sheet: www.tle-eliminators.com/cp-sheet
Solution Codes:
Problem A: www.codechef.com/viewsolution...
Problem B: www.codechef.com/viewsolution...
Problem C: www.codechef.com/viewsolution...
Problem D: www.codechef.com/viewsolution...
Be sure to check out TLE Eliminators.
Website: www.tle-eliminators.com/
Instagram: / tle_eliminators
Linkedin: / tle-eliminators
Twitter: / tle_eliminators
TLE Community Discord Server: / discord
Timestamps:-
0:00 Problem A
14:54 Problem B
43:00 Problem C
1:21:30 Problem D
Please fill the feedback form: forms.gle/WdVAj6WUKMxkSbXF6
For problem C you can compute initial beauty in O(n) using pref sum
Great Explanation
i was able to do 2 of them... thanks for the explanation , it helps us upsolve our contests.
Great explanation thanks alot to the TLE team 🙌.
Thnx for the explanations bro, they were great!
Lovely explanation sir🔥🔥🔥
great explanation💯
There is no need to use set we can check beauty by prefix sum if it is equal to i*(i+1)/2 or sum-arr[i]+arr[i+1] is equal to i*(i+1)/2 . This approach will solve the question in O(n) for question. 3
b and c explanation was so goood!!
kuch bhi , b m formula kse aaya btaya hi nahi !!
July batch kab launch hoga?
In C why initial beauty + mx is the ans ? While swapping element in any subarray to get mx wouldn't the initial beauty will also get affected?
No, becuz we are also taking negative one (-1) in cosideration from 'vec' while finding 'mx' that's why the change you're talking about will also get counted while finding the 'mx' itself!
The code for the second problem is not working : third output is coming in negative .... Can you provide the correct code !!
Use "long long"
I have defined my int as long long, that's y its working.
#include
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector vi;
typedef vector vll;
typedef vector vvi;
typedef vector vs;
typedef vector vvs;
typedef pair pii;
typedef vector vpii;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
cin >> t;
for (int i = 0; i < t; i++)
{
ll n, k, h;
cin >> n >> k >> h;
ll ans = 0;
for (ll i = 1; i =h)
ans += n;
else
{
ll r = (k*a-h)/(k-1);
if(r>0) ans+=r;
}
}
cout
i did it with binary search
#include
using namespace std;
#define ll long long int
bool canEscape(ll A, ll B, ll H, ll K) {
if (A >= H) return true;
if (A N >> K >> H;
ll count = 0;
ll low = 1;
ll high = N;
ll minA = 2;
while (low
In the first question if the array is [2 2 2 2 2 3 3 3 3 3 3] -> converting all elements to 2 would cost 6*2=12 and converting all elements to 3 would cost 5*3=15 , but instead we can convert all the elements to one and the cost would be 11 but your code would output 12 but the optimal is 11 please have a look.
I have checked *for every x from 1 to n* ,
so when x=1, we get freq[x]=0, so (n-0)*1 is going to give me the optimal answer of 11 for the test case you mentioned.
You can look at my code, i run a loop *for(int i=1;i
Can someone pls tell why this code fails i have checked its the same logic
#include
using namespace std;
typedef long long ll;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
const int mod = 1e9 + 7;
int main() {
// your code goes here
int t;
cin >> t;
while(t--){
int n;
cin >> n;
std::vector arr(n);
vector mp(n+1);
for(int i=0; i> arr[i];
mp[arr[i]]++;
}
int ans = 1e9;
for(int i=1; i
You need to use "long long" instead of int
bhai sab kuch bdia h bas network sahi karlo voice bhot break ho rhi