Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 100;
- const int X = 500;
- int arr[N + 1];
- bool dp[N + 1][X + 1][X + 1];
- int main(){
- int nArea;
- scanf("%d", &nArea);
- int sum = 0;
- for(int i = 1; i <= nArea; ++i){
- scanf("%d", &arr[i]);
- sum += arr[i];
- }
- if(sum % 3 != 0){
- cout << "noob";
- return 0;
- }
- int tr = sum / 3;
- for(int i = 0; i <= nArea; ++i){
- dp[i][0][0] = true;
- }
- for(int i = 1; i <= nArea; ++i){
- for(int x = 0; x <= tr; ++x){
- for(int y = 0; y <= tr; ++y){
- if(x == 0 && y == 0){
- dp[i][x][y] = true;
- continue;
- }
- bool ans = false;
- if(x >= arr[i]){
- ans |= dp[i - 1][x - arr[i]][y];
- }
- if(y >= arr[i]){
- ans |= dp[i - 1][x][y - arr[i]];
- }
- ans |= dp[i - 1][x][y];
- dp[i][x][y] = ans;
- }
- }
- }
- if(dp[nArea][tr][tr]){
- cout << "mission complete";
- } else {
- cout << "noob";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement