답안 #74278

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
74278 2018-08-30T19:44:46 Z Vardanyan Bali Sculptures (APIO15_sculpture) C++14
0 / 100
86 ms 94996 KB
//#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int A[N];
int K;
int n;
vector<long long> dp[N][N];
int main()
{
    int a,b;
    scanf("%d%d%d",&n,&a,&b);
    for(int i = 1;i<=n;i++) scanf("%d",&A[i]);
    long long c = 0;
    for(int i = 1;i<=n;i++){
        c+=A[i];
        dp[i][1].push_back(c);
    }
    long long ans = 10000000000000007;
    for(int k = 2;k<=b;k++){
        for(int i = k;i<=n;i++){
            c = A[i];
            for(int j = i-1;j>=1;j--){
                for(int q = 0;q<dp[j][k-1].size();q++){
                    dp[i][k].push_back(dp[j][k-1][q]|c);
                    if(k>=a && i == n) ans = min(ans,dp[j][k-1][q]|c);
                }
                c+=A[j];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:24:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int q = 0;q<dp[j][k-1].size();q++){
                               ~^~~~~~~~~~~~~~~~~~
sculpture.cpp:12: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:13:34: 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]);
                             ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 94712 KB Output is correct
2 Correct 78 ms 94844 KB Output is correct
3 Incorrect 78 ms 94920 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 94920 KB Output is correct
2 Correct 78 ms 94920 KB Output is correct
3 Incorrect 78 ms 94920 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 94920 KB Output is correct
2 Correct 78 ms 94920 KB Output is correct
3 Incorrect 78 ms 94920 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 94920 KB Output is correct
2 Correct 80 ms 94996 KB Output is correct
3 Incorrect 86 ms 94996 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 94996 KB Output is correct
2 Correct 78 ms 94996 KB Output is correct
3 Incorrect 80 ms 94996 KB Output isn't correct
4 Halted 0 ms 0 KB -