ECMAR20A - Editorial

PROBLEM LINK:

Practice
Contest Link

Author: Shekhar Srivastava
Tester: Sandeep Singh
Editorialist: Shekhar Srivastava

DIFFICULTY:

CAKEWALK

PREREQUISITES:

None

PROBLEM:

An AI predicts the temperature of some place. You are given the temperature predicted by the AI p, the actual temperature t and the allowed error e in the predicted temperature. you have to print “PASSED” if error in predicted temperature is less than equal to the allowed error e else you have to print “FAILED”

EXPLANATION:

you have to simply take the absolute value of the difference between the temperature predicted by the AI p and the actual temperature t then you have to print “PASSED” if this value is less than equal to the allowed error else you have to print “FAILED”

absolute_difference = |t-p|
print “PASSED” if absolute_difference \leq e else print “FAILED”

SOLUTIONS:

Setter's Solution
for _ in range(int(input())):
    t,p,e = map(int,input().split())
    abs_diff = abs(t-p)
    if abs_diff<=e: 
        print("PASSED")
    else:
        print("FAILED")
Tester's Solution
#include <bits/stdc++.h>
#define ll long long int
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define scanarr(a,b,c) for( i=b;i<c;i++)cin>>a[i]
#define showarr(a,b,c) for( i=b;i<c;i++)cout<<a[i]<<' '
#define ln cout<<'\n'
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
#define MAX 100005
using namespace std;
////////////////////////////////////////////////////////////////CODE STARTS HERE////////////////////////////////////////////////////////////////
 
void solve(){
    int n,i,j,a,b,c;
    cin>>a>>b>>c;
 
    if(abs(a-b)<=c)
        cout<<"PASSED";
    else
        cout<<"FAILED";
    ln;
}   
int main(){
    #ifndef ONLINE_JUDGE
    freopen("ipo.in","r",stdin);
    freopen("op0.out","w",stdout);
    #endif
    int t;
    cin>>t;
    while(t--)
        solve();
    } 
2 Likes