I did the exact same thing, but unfortunately the test cases are so weak that it passes. However this solution is O(n^3) and will never pass the extreme value of 2500.

Active In

Competitive Programming

International Olympiad in Informatics

Indian Computing Olympiad (ICO)

Featured Contributions

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 50w

I did the exact same thing, but unfortunately the test cases are so weak that it passes. However this solution is O(n^3) and will never pass the extreme value of 2500.

Read more… (31 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 50w

On second thought, this code passes the test cases on codechef because they are weak. I came up with this solution when I was afraid of DP. This code will not pass if there are 2500 bamboo shoots.

Read more… (38 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 50w

While Keshav' s solution is time optimal, it is also necessary to check out the time constraints during competitive programming.

If you are given 1 second, you could just solve it in 0.99 second and get 100% marks.

There is a O(n log n) solution to this problem which requires almost zero thinking.

Also the test cases for this problem are extremely weak. I got it AC in 0.07 after using the O(n log n) solution. I daresay even a O(n^3) solution will pass this problem.

Read more… (106 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 50w

We can just use the the std::next_permutation() in C++, right?

Read more… (10 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 50w

Solution ahead:

//priyanshul//Break Up (DP)#include <bits/stdc++.h>using namespace std;bool isPal(int arr[] , int i , int j){if(i==j)return true;while(i<=j){if(arr[i] != arr[j])return false;i++;j--;}return true;

Read more… (2 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 51w

Completed in 0.00 sec. Here is my solution if anyone needs help:

#include <bits/stdc++.h>using namespace std;struct range{int start , end;};bool comparator(range a , range b){return (a.start < b.start);}int main(){ios::sync_with_stdio(false);cin.tie(NULL);int N;cin>>N;

Read more… (12 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 51w

Are you sure this works? Because, I made a code with the exact same logic, only difference being instead of vector, I made an array of structure; and it does not work.

Read more… (32 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 51w

I feel my code is correct and I have been going over it for 2 days now, and I cannot possible find any error. It qualifies 5/15 test cases only.

Please look into my code and point out my mistake.

#include <bits/stdc++.h>using namespace std;int main(){ios::sync_with_stdio(false);cin.tie(NULL);int N,X,Y;cin>>N>>X>>Y;

Read more… (40 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 51w

//priyanshul//Bamboo Art ZCO 2016#include <bits/stdc++.h>using namespace std;int main(){int N;cin>>N;int arr[N];for(int i=0 ; i<N ; ++i)cin>>arr[i];sort(arr,arr+N);int diff = 0;int maxm=0;for(int i=0 ; i<N ; i++)for(int j=i+1 ; j<N ; j++){diff = arr[j] - arr[i];for(int k=2 ; k<N ; k++)if(!binary_search( arr , arr+N , arr[i] + diff*k)){if(k-1>maxm)maxm = k-1;break;}}cout<<maxm+1;}

For anyone who needs a short solution w/o DP.

Read more… (9 words)

comment in this discussion

PG

Priyanshul GovilNot just another programmer. · 51w

#include <iostream>#include <algorithm>using namespace std;int main(){long long M;cin>>M;long long arr[M];long long x,y;for(long long i=0 ; i<M ; i++){//since the block can be made into a square box with highest dimension equal//to the smaller dimension of the boxcin>>x>>y;arr[i] = min(x,y);}

Read more… (37 words)