def is_score_possible(score, total_questions, score_true, score_false): """Cek apakah skor bisa didapatkan dari kombinasi benar, salah, kosong.""" for benar in range(total_questions + 1): for salah in range(total_questions - benar + 1): kosong = total_questions - benar - salah total_score = benar * score_true + salah * (-score_false) if total_score == score: return "YA" return "TIDAK" def process_data(lines): results = [] for line in lines: nums = list(map(int, line.strip().split())) if len(nums) != 4: results.append("FORMAT SALAH") continue score, total, benar, salah = nums hasil = is_score_possible(score, total, benar, salah) results.append(hasil) return results # Contoh input data_input = [ "80 10 5 1", "90 100 1 1", "99 10 5 5", ] # Proses dan cetak hasil hasil = process_data(data_input) for i, res in enumerate(hasil, 1): print(f"h#{i}: {res}")