Getting Wrong Answer

Hi Guys,
I am trying to solve:
question link

I thought as we can reduce a given rectangle to a given size cube.I stored the minimum of the dimensions of given rectangle in a c++ set and the answer would be equal to size of the set. But I am getting wrong ans.
Please let me know if my approach is correct or any testcase to prove its wrong.(As I am getting wrong answer )
Here’s the code:

#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;
	scanf("%d",&n);
	int a,b;
	set<int> s;
	for(int i=0;i<n;i++){
		scanf("%d%d",&a,&b);
		s.insert(min(a,b));
	}
 
	printf("%d\n",s.size());
	return 0;

}

I think the problem is here-

Input

2
100 2
2 100

Output
1

Expected Output 
2

One of the 100x 2 block can be shaved to 1x1, and other into 2x2, and thus a pyramid of height 2 is possible.

1 Like

Other than what @vijju123 mentioned, you should be using long, not int (As the constraints are <=10^6)

Thanks dear!

BTW I think int can comfortable deal with values upto 10^8 and 10^9. Can you please check it once again? :slight_smile:

1 Like

Oh wow, that was quite dumb of me. I always assumed int to be of 16 bits and long to be 32 bits. Turns out both are 32 bit. Thanks buddy!

Ohk! Thanks for confirmation! Yeah…it makes a difference in JAVA afaik. Sometimes things get confusing when learning multiple languages XD

Thanks! it helped.

I hope you get the problem soon. Your thought process is quite sharp, i have to admit! :slight_smile: