# KARATEKID - Editorial

Tester: Yogesh Deolalkar
Editorialist: Ram Agrawal

SIMPLE

# PREREQUISITES:

Conditional Statement

# PROBLEM:

Dre is a karate student. To achieve his next belt, he has to give a test. Dre wants to check if he can pass the test or not. He needs your help in determining so.

His strength is S. In the test, Dre has to break N tiles where the width of each tile is W. Strength of a tile can be calculated by multiplying its width by a factor X. Dre can break the tiles if his strength is greater than or equal to the strength of tiles.

Given X, help Dre find if he can pass the test or not.

# QUICK EXPLANATION:

Strength of all The tiles is calculated by multiplying Number of tiles ( N) by its width (W) and Factor (X).
So, Dre can break the tiles if his strength is greater than or equal to the strength of tiles.

# SOLUTIONS:

Setter's Solution
from sys import stdin
if(n*w*x<=s):
print("YES")
else:
print("NO")

Editorialist's Solution
#include <iostream>
using namespace std;

int main() {
int T;
long long N,S,W,X,tilestrength,totaltilestrength;
cin>>T;
while(T--)
{
cin>>N>>S>>W>>X;
tilestrength=W*X;
totaltilestrength=N*tilestrength;
if(S>=totaltilestrength)
{
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
}
return 0;
}


The fact that this submission resulted in \red{\text{RTE}} while other submissions (attached below) resulted in \green{\text{AC}} is really annoying me.

When I checked the maximum value we can store in a long long int (LLONG_MAX), it turned out to be 2^{63} - 1 (from the following program). Why was that CPP Submission accepted?

LLONG MAX
#include <bits/stdc++.h>
using namespace std;

int main() {
cout << LLONG_MAX << '\n';
cout << (LLONG_MAX == ((1ULL << 63) - 1) ? 1 : 0) << '\n';
return 0;
}


It is just a case of weak test cases .
c++11 - Is signed integer overflow still undefined behavior in C++? - Stack Overflow

It states that signed integer overflow is undefined behaviour .
1H8IcH - Online C++0x Compiler & Debugging Tool - Ideone.com

just a small example

1 Like