33 lines
527 B
C++
33 lines
527 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int N, T;
|
|
vector<int> nums;
|
|
|
|
bool solve(int idx, int sum)
|
|
{
|
|
if (sum == T) return true;
|
|
if (idx == N) return false;
|
|
if (sum > T) return false;
|
|
|
|
return solve(idx + 1, sum + nums[idx]) || solve(idx + 1, sum);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
cin >> N;
|
|
cin >> T;
|
|
nums.resize(N);
|
|
for (int i = 0; i < N; i++)
|
|
cin >> nums[i];
|
|
|
|
if (solve(0, 0)) {
|
|
cout << "PERFEITO!";
|
|
} else {
|
|
cout << "IMPOSSIVEL!";
|
|
}
|
|
cout << endl;
|
|
|
|
return 0;
|
|
} |