Submission #23420

# Submission time Handle Problem Language Result Execution time Memory
23420 2017-05-09T05:53:59 Z rubabredwan Bali Sculptures (APIO15_sculpture) C++14
0 / 100
0 ms 2036 KB
/* Bismillahir Rahmanir Rahim */

#include <bits/stdc++.h>

using namespace std;

const int N = 2005;
const int oo = 1e9;

int n, a, b, y[N];
int dp[N];

long long lst(long long mask){
    if(!mask) return -1;
    return 63 - __builtin_clzll(mask);
}

bool OK(long long fixed, long long bit){
    dp[0] = 0;
    for(int i=1;i<=n;i++){
        dp[i] = oo;
        long long sum = 0;
        for(int j=i;j>=1;j--){
            sum += y[j];
            if(lst(sum^fixed) < bit){
                dp[i] = min(dp[i], dp[j-1] + 1);
            }
        }
    }
    if(dp[n] <= b) return true;
    else return false;
}


int main(){
    scanf("%d %d %d", &n, &a, &b);
    for(int i=1;i<=n;i++) scanf("%d", &y[i]);
    long long ret = 0;
    for(long long bit=41;bit>=0;bit--){
        if(!OK(ret, bit)){
            ret |= (1LL << bit);
        }
    }
    cout << ret << endl;
	return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:36:34: 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:37:45: 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", &y[i]);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2036 KB Output is correct
2 Incorrect 0 ms 2036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2036 KB Output is correct
2 Incorrect 0 ms 2036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2036 KB Output is correct
2 Incorrect 0 ms 2036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2036 KB Output is correct
2 Incorrect 0 ms 2036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2036 KB Output is correct
2 Incorrect 0 ms 2036 KB Output isn't correct
3 Halted 0 ms 0 KB -