My issue
My code
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: PRACTICEPERF Problem - CodeChef
#include <iostream>
using namespace std;
int main() {
// your code goes here
return 0;
}
Problem Link: PRACTICEPERF Problem - CodeChef
Given the number of problems chef solved each week for 4 weeks, we want to find if he beat his goal of solving at least 10 problems. Hence given 4 numbers p_1, p_2, p_3, p_4 (where p_i is the problems chef solved on the i-th week), we need to find if p_i \ge 10 (where 1 \le i \le 4).
In code:
#include <iostream>
using namespace std;
int main() {
int ans = 0;
for (int i = 0; i < 4; ++i) {
int p; cin >> p;
if (p >= 10) ans++;
}
cout << ans << '\n';
return 0;
}
Here we use ans as the total number of weeks he did passed his goal (initially 0). Since we know there are only 4 numbers, we iterate over the range [0,3], take the input of the i-th week’s problems solved and check if its greater than or equal to 10. If it is, then we increment our answer by 1.