답안 #49910

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49910 2018-06-04T20:56:30 Z kjain_1810 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 724 KB
#include<bits/stdc++.h>

using namespace std;
const int N=1e2+5;
int arr[N], dp[N][N], n, m, A, B, pref[N];
//dp[i][j]==dividing first i numbers in j parts
int main()
{
    scanf("%d%d%d", &n, &A, &B);
    for(int a=1; a<=n; a++)
        scanf("%d", &arr[a]);
    for(int a=1; a<=n; a++)
        pref[a]=pref[a-1]+arr[a];
    for(int a=1; a<=n; a++)
        dp[a][1]=pref[a];
    int ans=INT_MAX;
    if(A==1)
        ans=dp[n][1];
    for(int a=2; a<=B; a++)
    {
        for(int b=a; b<=n; b++)
        {
            dp[b][a]=INT_MAX;
            for(int c=b-1; c>=a-1; c--)
                dp[b][a]=min(dp[b][a], dp[c][a-1]|(pref[b]-pref[c]));
        }
        if(a>=A)
            ans=min(ans, dp[n][a]);
    }
    printf("%d\n", ans);
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &A, &B);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[a]);
         ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 412 KB Output is correct
2 Incorrect 2 ms 540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 540 KB Output is correct
2 Incorrect 2 ms 540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 540 KB Output is correct
2 Incorrect 2 ms 540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 540 KB Output is correct
2 Incorrect 2 ms 724 KB Output isn't correct
3 Halted 0 ms 0 KB -