Exam Time | EXMTIME

PROBLEM LINK:

Exam Time - Submit | CodeChef
Setter: Sidharth Sethi
Tester: Ramandeep Singh
Editorialist: Sidharth Sethi

DIFFICULTY:

Cakewalk

PREREQUISITES:

Basic Math

PROBLEM:

Ayush is preparing for his final exams after obtaining his internal result. He wants at least 60% in all the exams. The exam will be 70 marks and the internals were 30 marks. He wants to know the minimum marks required in the exams to obtain his goal.

EXPLANATION:

To solve this problem, all we have to do is to make a loop of n iterations to gather all the inputs and after that just subtract all the inputs from 60 to print out the resulting score.

TIME COMPLEXITY:

O(N) per test case.

SOLUTIONS:

Setter’s Solution -

#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int required_marks = 60;
        while (n--)
        {
            int marks;
            cin >> marks;
            cout << required_marks - marks << " ";
        }
        cout << "\n";
    }
    return 0;
}

Tester’s Solution -

#include <bits/stdc++.h>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
 
 
#define watch(x)           cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val)         memset(d,val,sizeof(d))
#define setp(x)             cout<<fixed<<setprecision(x)
#define loop(i,a,b)         for(int i=(a);i<(b);i++)
#define hunt(i,a,b)         for(int i=(a);i<=(b);i++)
#define lp(i,a,b)           for(int i = a; i >= b; i--)
#define rep(i,n)            for(int i = 0; i < n; i++)
#define int                 long long int 
#define pb                  push_back
#define f                   first
#define s                   second
#define pqueue              priority_queue
#define fbo                 find_by_order
#define ook                 order_of_key
#define ll                  long long
#define ii                  pair<int,int>
#define vi                  vector<int>
#define vii                 vector<ii>
#define ld                  long double 
#define all(x)              begin(x),end(x)
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
ll Bexp(ll a,int b){ ll ret=1; for (;b;a=a*a,b>>=1) if (b&1) ret=ret*a; return ret; }
ll gcd(ll A , ll B)
{
  if(B == 0)return A;
  return gcd(B , A%B);
}
ll min(ll a , ll b){return a > b ? b : a;}
ll max(ll a , ll b){return a > b ? a : b;}
/*
int mod(a, b) {
  c = a % b
  return (c < 0) ? c + b : c
 
*/
int mod(int a, int b) {
  return (((a % b) + b) % b);
}
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
 
//Always check odd-even using AND and never using MODULO
bool is_odd(int n) {
    return n & 1 != 0;
}
 
void The_Hawk_returns()
{
#ifndef vjudge
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


void solve(int test){
      int n;
      cin >> n;
      rep(i,n){
         int x;
         cin >> x;
         cout << 60-x << " ";
      }
      cout << "\n";
} 
 

int32_t main() {
    
    The_Hawk_returns();
    int t=1;
    cin >> t;
    for(int test=1;test<=t;test++){
      solve(test);
    } 
}