제출 #91396

#제출 시각아이디문제언어결과실행 시간메모리
91396Aydarov03K개의 묶음 (IZhO14_blocks)C++14
53 / 100
2 ms868 KiB
    #include <bits/stdc++.h>
    using namespace std;
    int a[101] , dp[101][101];


    main()
    {
        int n , k;
        cin >> n >> k;
        for(int i = 1; i <= n; i++)scanf("%d" , &a[i]);

        for(int i = 1; i <= n; i++)dp[1][i] = max( a[i] , dp[1][i-1] );


        for(int i = 2; i <= k; i++)
        {

            for(int j = i; j <= n; j++)
            {
                int mx = a[j];
                dp[i][j] = dp[i-1][j-1] + a[j];
                for(int t = j; t >= i; t--)
                {
                    mx = max(mx , a[t]);
                    dp[i][j] = min( dp[i][j] , dp[i-1][t-1] + mx);
                }
            }
        }

        cout << dp[k][n];

    }

컴파일 시 표준 에러 (stderr) 메시지

blocks.cpp:6:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
     main()
          ^
blocks.cpp: In function 'int main()':
blocks.cpp:10:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int i = 1; i <= n; i++)scanf("%d" , &a[i]);
                                    ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...