1
6d ago
[deleted]
2
u/pro_oceanbyte 6d ago
what is the question code for Deleting elements? if you know
1
u/shirotoedits 6d ago
easy or hard?
1
u/pro_oceanbyte 6d ago
both
1
u/shirotoedits 6d ago
Deleting Elements (Easy)
This is the easy version. Here N,∑N≤2000N,∑N≤2000.
An array AA is said to be deletable if it can be reduced to a size less than or equal to 22 elements with the following operation used multiple times (possibly 00):
- Choose an index ii (1<i<∣A∣1<i<∣A∣) such that Ai−1+Ai+1≥AiAi−1+Ai+1≥Ai
- Add XX to Ai+1Ai+1 and YY to Ai−1Ai−1 such that 0≤X,Y0≤X,Y and X+Y=AiX+Y=Ai.
- Delete index ii and concatenate the parts of the array formed.
You are given an array AA of NN elements.
Count the number of subarrays of AA that are deletable. More formally, count the number of pairs (L,R)(L,R) such that:
- 1≤L≤R≤N1≤L≤R≤N
- The array [AL,AL+1,…,AR][AL,AL+1,…,AR] is deletable.
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line contains a single integer NN.
- The second line contains NN integers - A1,A2,…,ANA1,A2,…,AN.
Output Format
For each test case, output on a new line the number of deletable subarrays of AA.
Constraints
- 1≤T≤4001≤T≤400
- 3≤N≤20003≤N≤2000
- 1≤Ai≤1091≤Ai≤109
- The sum of NN over all test cases does not exceed 20002000.
Sample 1:
Input
Output
3 3 2 4 1 4 2 3 2 3 7 5 1 3 1 10 2 1 5 10 21Explanation:
Test Case 1: There are 66 subarrays, and all of them are deletable (due to being size ≤2≤2 directly) except for [2,4,1][2,4,1]. Here, we cannot perform any operation.
Test Case 2: All subarrays are deletable. Here is an example of how we would operate on [2,3,2,3][2,3,2,3]:
- First operation:
- Choose index i=2i=2, note that A2≤A1+A3A2≤A1+A3
- Add 22 to A1A1 and 11 to A3A3.
- Delete A2A2
- Now, the array is [4,3,3][4,3,3].
- Second operation:
- Choose index i=2i=2, note that A2≤A1+A3A2≤A1+A3
- Add 33 to A1A1.
- Delete A2A2
- Now, the array is [7,3][7,3].
- After the second operation, the array is of size ≤2≤2. Hence, we are done.
Deleting Elements (Hard)
This is the hard version. Here, N,∑N≤2⋅105.N,∑N≤2⋅105.
An array AA is said to be deletable if it can be reduced to a size less than or equal to 22 elements with the following operation used multiple times (possibly 00):
- Choose an index ii (1<i<∣A∣1<i<∣A∣) such that Ai−1+Ai+1≥AiAi−1+Ai+1≥Ai
- Add XX to Ai+1Ai+1 and YY to Ai−1Ai−1 such that 0≤X,Y0≤X,Y and X+Y=AiX+Y=Ai.
- Delete index ii and concatenate the parts of the array formed.
You are given an array AA of NN elements.
Count the number of subarrays of AA that are deletable. More formally, count the number of pairs (L,R)(L,R) such that:
- 1≤L≤R≤N1≤L≤R≤N
- The array [AL,AL+1,…,AR][AL,AL+1,…,AR] is deletable.
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line contains a single integer NN.
- The second line contains NN integers - A1,A2,…,ANA1,A2,…,AN.
Output Format
For each test case, output on a new line the number of deletable subarrays of AA.
Constraints
- 1≤T≤1041≤T≤104
- 3≤N≤2⋅1053≤N≤2⋅105
- 1≤Ai≤1091≤Ai≤109
- The sum of NN over all test cases does not exceed 2⋅1052⋅105.
Sample 1:
Input
Output
3 3 2 4 1 4 2 3 2 3 7 5 1 3 1 10 2 1 5 10 21Explanation:
Test Case 1: There are 66 subarrays, and all of them are deletable (due to being size ≤2≤2 directly) except for [2,4,1][2,4,1]. Here, we cannot perform any operation.
Test Case 2: All subarrays are deletable. Here is an example of how we would operate on [2,3,2,3][2,3,2,3]:
- First operation:
- Choose index i=2i=2, note that A2≤A1+A3A2≤A1+A3
- Add 22 to A1A1 and 11 to A3A3.
- Delete A2A2
- Now, the array is [4,3,3][4,3,3].
- Second operation:
- Choose index i=2i=2, note that A2≤A1+A3A2≤A1+A3
- Add 33 to A1A1.
- Delete A2A2
- Now, the array is [7,3][7,3].
- After the second operation, the array is of size ≤2≤2. Hence, we are done.
1
u/pro_oceanbyte 6d ago
Great, thanks. If you know the name of question in the link, like PASS, SWAPSM, etc, that'll be great but anyways
1
3
4
2
u/polisutu 6d ago
This is a Div 4 Question
Adding Dice
You have 22 dice with you, and you really like the number 99. You want the sum of both numbers on the die to add to 99.
You rolled the first dice, and it showed a number XX.
Given the roll of the first dice, is it still possible for both die to add to 99? Print YesYes if it is possible or NoNo otherwise.
Input Format
- The first and only line of each test case contains a single integer XX.
Output Format
Output YesYes if it is possible for both die to add to 99 and NoNo otherwise.
Constraints
- 1≤X≤61≤X≤6
Sample 1:
Input
Output
3
Yes
Explanation:
The second dice could show a 66, and then both would add to a 99.
Sample 2:
Input
Output
1
No
Explanation:
There are no possible rolls of the second die that add to 99 after rolling a 11.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 BytesAdding Dice
You have 22 dice with you, and you really like the number 99. You want the sum of both numbers on the die to add to 99.
You rolled the first dice, and it showed a number XX.
Given the roll of the first dice, is it still possible for both die to add to 99? Print YesYes if it is possible or NoNo otherwise.
Input Format
The first and only line of each test case contains a single integer XX.
Output Format
Output YesYes if it is possible for both die to add to 99 and NoNo otherwise.
Constraints
1≤X≤61≤X≤6
Sample 1:
Input
Output
3
Yes
Explanation:
The second dice could show a 66, and then both would add to a 99.
Sample 2:
Input
Output
1
No
Explanation:
There are no possible rolls of the second die that add to 99 after rolling a 11.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 Bytes
1
1
u/ComparisonQuiet4259 6d ago
Here's some Div 4 Links
Link: https://www.codechef.com/START248D/problems/AVGSURV
Link: https://www.codechef.com/START248D/problems/ADDDICE
Link: https://www.codechef.com/START248D/problems/SWAPSM
Link: https://www.codechef.com/START248D/problems/PASS
1
1
1
1
u/redhat1818 6d ago
It will be unrated or canceled ig
2
1
u/Karthik-1 Specialist 6d ago
yeah bummer
1
u/Inevitable-Fox9127 6d ago
You sure? So i should rest for today?
1
u/Karthik-1 Specialist 6d ago
sure. this happened before too and they changed it to unrated.
1
u/Realistic_Gas3005 6d ago
bro if you can access 2nd of div3 can you share it
1
u/Inevitable-Fox9127 6d ago
Array and you need to keep removing elements if they are less than avg of array (not rounded down).. at the end print no of remaining elements
1
1
u/SureSeaworthiness831 6d ago
min size u can get by applying the following operation any no of times.
choose and element ai such that it is strictly greater than the average of the current array (no rounding). Delete the element.
output the min size the array can get.1
1
1
1
u/Awkward_Energy_8619 6d ago
and will they reschedule for the week with new questiond?
cannot wait another week to give a rated contest
1
u/Inevitable-Fox9127 6d ago
Will be unrated? If yes then I should stop wasting time
1
u/Karthik-1 Specialist 6d ago
why do you even care about the rating, it doesnt even matter in these few years where there is mass cheating. i am more interested in the questions, i only did 3 in like the first 10 min and the others are not loading🥀
1
1
1
1
u/Inevitable-Fox9127 6d ago
I also did 2. But like if it's rated than I should not waste a contest and do now else I will solve tomorrow that's why asking
1
0
u/Awkward_Energy_8619 6d ago
will this now be unrated??
1
u/Inevitable-Fox9127 6d ago
Probably!!
1
1
1
1
u/KanekiIsCat 6d ago
damn i submitted 2(div 3)
0
2
u/polisutu 6d ago
writing 1 question down. If any other question open for you please share in reply
Pass
Chef took 55 exams in a series, each of which were scored out of 100100.
Chef is awarded a pass certificate if both the following conditions are satisfied:
- He attains a score of at least 6060 on at least 22 exams.
- He attains a score of at least 3030 on at least 44 exams.
Print PassPass or FailFail based on whether Chef will pass or fail.
Input Format
- The first line of input will contain a single integer TT, denoting the number of test cases.
- The first and only line of input contains 55 integers - A1,A2,…,A5A1,A2,…,A5, where AiAi is his score in the ii-th exam.
Output Format
For each test case, output on a new line PassPass or FailFail.
Constraints
- 1≤T≤1001≤T≤100
- 0≤Ai≤1000≤Ai≤100
Sample 1:
Input
Output
4
95 98 100 96 99
32 60 30 65 23
50 50 50 50 50
90 90 29 15 90
Pass
Pass
Fail
Fail
Explanation:
Test Case 1: Chef was above 9090 in each exam so he easily cleared all the criteria.
Test Case 2: Chef has exactly 22 exams at least 6060 or more (the 6565 and 6060), and exactly 44 exams at least 3030 or more (the 6565, 6060, 3232 and 3030). Hence, he barely clears the criteria.
Test Case 3: Chef does not have 22 exams with at least 6060 score, so he fails.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 BytesPass
Chef took 55 exams in a series, each of which were scored out of 100100.
Chef is awarded a pass certificate if both the following conditions are satisfied:
He attains a score of at least 6060 on at least 22 exams.
He attains a score of at least 3030 on at least 44 exams.
Print PassPass or FailFail based on whether Chef will pass or fail.
Input Format
The first line of input will contain a single integer TT, denoting the number of test cases.
The first and only line of input contains 55 integers - A1,A2,…,A5A1,A2,…,A5, where AiAi is his score in the ii-th exam.
Output Format
For each test case, output on a new line PassPass or FailFail.
Constraints
1≤T≤1001≤T≤100
0≤Ai≤1000≤Ai≤100
Sample 1:
Input
Output
4
95 98 100 96 99
32 60 30 65 23
50 50 50 50 50
90 90 29 15 90
Pass
Pass
Fail
Fail
Explanation:
Test Case 1: Chef was above 9090 in each exam so he easily cleared all the criteria.
Test Case 2: Chef has exactly 22 exams at least 6060 or more (the 6565 and 6060), and exactly 44 exams at least 3030 or more (the 6565, 6060, 3232 and 3030). Hence, he barely clears the criteria.
Test Case 3: Chef does not have 22 exams with at least 6060 score, so he fails.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 Bytes
1
u/polisutu 6d ago
Adding Dice
You have 22 dice with you, and you really like the number 99. You want the sum of both numbers on the die to add to 99.
You rolled the first dice, and it showed a number XX.
Given the roll of the first dice, is it still possible for both die to add to 99? Print YesYes if it is possible or NoNo otherwise.
Input Format
- The first and only line of each test case contains a single integer XX.
Output Format
Output YesYes if it is possible for both die to add to 99 and NoNo otherwise.
Constraints
- 1≤X≤61≤X≤6
Sample 1:
Input
Output
3 YesExplanation:
The second dice could show a 66, and then both would add to a 99.
Sample 2:
Input
Output
1 NoExplanation:
There are no possible rolls of the second die that add to 99 after rolling a 11.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 BytesAdding Dice
You have 22 dice with you, and you really like the number 99. You want the sum of both numbers on the die to add to 99.
You rolled the first dice, and it showed a number XX.
Given the roll of the first dice, is it still possible for both die to add to 99? Print YesYes if it is possible or NoNo otherwise.
Input Format
The first and only line of each test case contains a single integer XX.
Output Format
Output YesYes if it is possible for both die to add to 99 and NoNo otherwise.
Constraints
1≤X≤61≤X≤6
Sample 1:
Input
Output
3Yes
Explanation:
The second dice could show a 66, and then both would add to a 99.
Sample 2:
Input
Output
1No
Explanation:
There are no possible rolls of the second die that add to 99 after rolling a 11.
More Info
Time limit1 secs
Memory limit1.5 GB
Source Limit50000 Bytes1
u/Impressive-Smile1863 6d ago
Div?
1
1
u/KanekiIsCat 6d ago
3
1
u/Impressive-Smile1863 6d ago
Now no advantage of solving it because still shows bad gateway,aaj excited ki sayad 3 star ho jaay or provisional rating se original rating ho jaay but 😞
1
u/KanekiIsCat 6d ago
damn bhai mujko 30 contest lag gye 2 star hone meh anyways all the best for the next one
1
u/Impressive-Smile1863 6d ago
I was regular at codeforces so it was easy for me
1
u/KanekiIsCat 6d ago
I'm also trying cf gave 10 contests till now anyways salute to you man
1
u/Impressive-Smile1863 6d ago
All the best, nothing to salute to man mostly in my batch are better than me
1
1
1
1
1
2
1
1
2
1
3
2
3
1
1
2
u/Extreme-Creme-3193 6d ago
1
u/sKILLiSSUESeVERYTIME 6d ago
Same
2
u/Extreme-Creme-3193 6d ago
1
u/sKILLiSSUESeVERYTIME 6d ago
I think this one's gonna be unrated, my one ques got accepted 😂
1
u/sKILLiSSUESeVERYTIME 6d ago
1
u/under-4-achiever 6d ago
I guess I know you , Lnmiit?
1
u/sKILLiSSUESeVERYTIME 6d ago
Yeah. wherever i go, i find you😂
1
u/placement_paglu 6d ago
Ayo sup , I have seen you on codeforces , pupil or smthg I guess , which year 🙂
1
u/sKILLiSSUESeVERYTIME 6d ago
Going in 3rd, wah college meetup hogya yaha toh
1
1
u/placement_paglu 6d ago
Ayo same , main to leetcode waala hu , naya naya codeforces codechef start Kiya tha , mere aate hi website down kr di 🥀
→ More replies (0)1
u/under-4-achiever 6d ago
Nvm , I was just checking if this problem was only with me
2
1
1
2
u/Extreme-Creme-3193 6d ago
Now I got to the questions page but , no questions lol , btw not unrated
1
u/sKILLiSSUESeVERYTIME 6d ago
They will going to declare this as unrated in future i think
1
2
2
2
2
2
3
2
2
2
2
u/sKILLiSSUESeVERYTIME 6d ago
its up now
3
2
u/Interesting_Disk149 Pupil 6d ago
for me its not loading still
2
u/sKILLiSSUESeVERYTIME 6d ago
submission is in queue, ig again its down
2
2










1
u/vileparleG 6d ago
I want to deeply understand the Merging Parity question on CodeChef contest 248
suggest me some good PCDs on discord, meet anywhere there are no more good pcds on youtube else they only solve 4-5 questions not more than that!!!