Submission #70652

#TimeUsernameProblemLanguageResultExecution timeMemory
70652evpipisBali Sculptures (APIO15_sculpture)C++11
71 / 100
54 ms2084 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int inf = 1e9; int dp1[105][105], dp2[2005], n, a, b, arr[2005]; bool solve1(ll x){ dp1[n+1][0] = 1; for (int i = n; i >= 1; i--) for (int k = 1; k <= b; k++){ ll sum = 0; dp1[i][k] = 0; for (int j = i; j <= n; j++){ sum += arr[j]; if ((sum|x) == x) dp1[i][k] |= dp1[j+1][k-1]; } } for (int k = a; k <= b; k++) if (dp1[1][k]) return true; return false; } bool solve2(ll x){ for (int i = n; i >= 1; i--){ ll sum = 0; for (int j = i; j <= n; j++){ sum += arr[j]; dp2[i] = inf; if ((sum|x) == x) dp2[i] = min(dp2[i], dp2[j+1]+1); } } return (dp2[1] <= b); } int main(){ scanf("%d %d %d", &n, &a, &b); for (int i = 1; i <= n; i++) scanf("%d", &arr[i]); ll ans = (1LL<<41)-1; for (int j = 40; j >= 0; j--){ if (solve1(ans^(1LL<<j))) ans ^= (1LL<<j); //if (a == 1 && solve2(ans^(1LL<<j))) // ans ^= (1LL<<j); } printf("%lld\n", ans); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:41: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:43:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &arr[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...
#Verdict Execution timeMemoryGrader output
Fetching results...