For DISHOWN July14 same solution in C++ 4.3.2 got TLE & got AC in C

For the problem DISHOWN in JULY14 challenge I first tried in C++ 4.3.2 and got TLE
then I uploaded the same code(of course changed cin & cout to scanf and printf) got AC in C.

Admin/Anyone please exlain the reasons for this:

C++ 4.3.2 Submission(TLE):

C Submission(AC):

Thank’s in Advance.

Yes ‘cin’ and ‘cout’ are slower than scanf() and printf().To make them faster you can use :

int main() {
     ios_base::sync_with_stdio(false); cin.tie(0);
    // rest of your code
    return 0;

Here are some of the links which may help you !

1 Like

@achaitanyasai Does that difference(cin & cout to printf & scanf) will cause this much effect I mean TLE to AC…??

It depends, if the constraints are tight(large) then you may have chance to get TLE if you use cin/cout. But in most of the cases it doesn’t matter.

@achaitanyasai Thanks… :slight_smile: