SHARE
TWEET

Untitled

a guest Apr 18th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 벚꽃이 정보섬에 피어난 이유
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <stdbool.h>
  6. #include <math.h>
  7. #include <limits.h>
  8. #define MAX 1001
  9.  
  10. int main(){
  11.    
  12.     int N, Max = 0, tmp = 0;
  13.     int arr[11] = {0,};
  14.     int dp[11][11] = {0,};
  15.    
  16.     scanf("%d", &N);
  17.     for( int i=1; i<=N; i++ ){
  18.         scanf("%d", &arr[i]);
  19.         dp[i][1] = arr[i];
  20.     }
  21.    
  22.     for( int i=2; i<=N; i++ ){
  23.         for( int j=1; j<=N-i+1; j++ ){
  24.             dp[j][i] = dp[j][i-1]*arr[j+i-1];
  25.         }
  26.     }
  27.    
  28.     for( int i=1; i<=N-3; i++ ){
  29.         for( int j=1; j<=N-3; j++ ){
  30.             for( int k=1; k<=N-3; k++ ){
  31.                 for( int l=1; l<=N-3; l++ ){
  32.                     if( i + j + k + l == N ){
  33.                         tmp = dp[1][i] + dp[1+i][j] + dp[1+i+j][k] + dp[1+i+j+k][l];
  34.                         Max = Max>tmp?Max:tmp;
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.     }
  40.     printf("%d", Max);
  41.     return 0;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top