Just realized last 1200ish was in Sep, 2020.1 month to go
Just realized last 1200ish was in Sep, 2020.1 month to go
hello I am stuck in this problem Digit Queries.I think I need to use recursion here although not quite sure how? Which algo or technique I need to study to solve this problem? Also please share similar types of problems from other ojs.Please help me with that.
Need help with this digit dp problem Almost Everywhere Zero from Atcoder. Here,I increase the $$$cnt$$$ value if the $$$i$$$ th digit is non zero.Base case is if cnt==k return 1 or 0
otherwise.My submission works for smaller values but fails larger inputs or maybe I am missing some cases.I also see others solutions but couldn't find one using reccursion in my approach. Need help here. Thank you
Hello, in this problem 1011 — Marriage Ceremoniesthe priority index is not clear to me. I used bottom up manner and calculate the max adjacent values.
5
5 10 10 2 3
2 11 3 10 10
16 12 1 5 2
4 2 11 5 2
1 8 14 4 13
Ans:60.Which for me 14 11 12 11 10
total 58
.What am I missing here? Need help with that.
I just completed CSES Sorting and Searching section problems. And I didn't find any editorials for this. So I am writing my own approach for the problems.Please do correct me if I made any mistakes and do share your approach for the problems.
My solutions are here
1.Distinct Numbers
2.Apartments
3.Ferris Wheel
4.Concert Tickets
5.Restaurant Customers
6.Movie Festival
7.Sum of Two Values
8.Maximum Subarray Sum
9.Stick Lengths
10.Playlist
11.Towers
12.Traffic Lights
13.Room Allocation
14.Factory Machines
15.Tasks and Deadlines
16.Reading Books
17.Sum of Three Values
18.Sum of Four Values
19.Nearest Smaller Values
20.Subarray Sums I
21.Subarray Sums II
22.Subarray Divisibility
23.Array Division
24.Sliding Median
25.Sliding Cost
26.Movie Festival II
27.Maximum Subarray Sum II
I was doing a problem from codechef Multiples of 3 but could not figure out why it's getting TLE? My submission. Thank you.
Hello.I was going through the problem Coin Combinations I which is similar to the next question Coin Combinations II.In Coin Combination II problem I used 2d array to store the dp values and used bottom up approach to solve it.The submission is here.Now I was wondering if Coin Combination I has the similar solution like II using 2d array ? I have gone through many solutions but none of these have used 2d array.So I could not come up with any idea.Please help me with this.
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,sum;
cin>>n>>sum;
vector<int>v(n);
for(int i=0;i<n;++i)
{
cin>>v[i];
}
int dp[n+1][sum+1];
memset(dp,0,sizeof(dp));
dp[0][0]=1;
for(int i=1;i<=n;++i)
{
for(int j=0;j<=sum;++j)
{
if(j>=v[i-1])
{
//Condition
dp[i][j]%=mod;
}
}
}
cout<<dp[n][sum]<<endl;
return 0;
}
In this problem Kuriyama Mirai's Stones I used segment tree for the sum of range of queries.Firstly I created two segment tree (1st for unsorted array)(2nd for sorted array).For every t=1 I used query in unsorted seg_tree and t=2 I used query in sorted seg_tree.Which I know that creating segment tree is in O(n) and query is O(log(n)).But I have TLE for this approach.How can I upgrade this approach? My submission is here.
In this problem , I take the input and I store every value in ith index to a map.If my map[i] has a value than I push both map[i] and i to a vector pair. Here in worst case the code may run in 2*n times which is so to say O(n)times.But how I am getting here TLE with O(n) times? My submission is here.
Hello I have been trying to solve this problem using basic star pattern logic. My approach is — first create the upper half of the pyramid and then add the next portion of the pyramid.For that I first initialize all the elements of the 2d array in null value**('\0')**.And my compiler shows the exact same result as in the description.But somehow codeforces compiler showing weird symbols for ('\0') .I have also tried char(0) which also give me weird symbols.My submissions here and here.How can I get ac from this submission?
1111A - Трансформация супергероев I have tried map for tracking either a char is vowel or consonant.And then comparing both the map's element, I may have my expected solution.But implementing map it came to my mind that map is a sorted container.So I google it and from stackoverflow I found this articlefifo_map which actually acts according to plan.But using above mentioned way I have a compilation error(No such directory).Is there any way to include external headers? My submission is here