My issue
while using ternary operator instead of (if/else) it is giving WA : wrong answer while submitting it and if i’m using if-else it is giving correct o/p what could be the reason ?
My code
#include<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t; cin >> t;
while(t--) {
int people , days;
cin >> people >> days;
int risk = 0 , safe = 0 , ans1 = 0;
while(people--) {
int x; cin >> x;
if (x >= 80 || x <= 9) risk++;
else safe++;
}
ans = (risk&1) ? (risk/days)+1 : risk/days;
ans += (safe&1) ? (safe/days)+1 : safe/days;
cout << ans << '\n';
}
}
Problem Link: VACCINE2 Problem - CodeChef