Submission #260098

#TimeUsernameProblemLanguageResultExecution timeMemory
260098pure_memBali Sculptures (APIO15_sculpture)C++14
50 / 100
180 ms504 KiB
#include <bits/stdc++.h> #define ll long long #define X first #define Y second #define MP make_pair using namespace std; const int N = 2e3 + 2; int A, B, n, dp[N]; ll pr[N], ans; bool sub_mask(ll x, ll y, ll idx){ x >>= idx, y >>= idx; if((x & y) != y){ return 0; } return 1; } bool check(ll idx){ //memset(dp, 0, sizeof(dp)); for(int i = 1;i <= n;i++) dp[i] = n + 2; dp[0] = 0; for(int i = 1;i <= n;i++){ for(int j = 0;j < i;j++){ //cerr << ans << " " << pr[i] - pr[j] << "\n"; if(sub_mask(ans, pr[i] - pr[j], idx)){ dp[i] = min(dp[i], dp[j] + 1); } } } //cerr << dp[n] << "\n"; if(dp[n] < A || dp[n] > B) return 0; return 1; } int main () { scanf("%d %d %d", &n, &A, &B); for(int i = 1, x;i <= n;i++){ scanf("%d", &x), pr[i] = pr[i - 1] + x; } for(ll idx = 50;idx >= 0;idx--){ if(!check(idx)){ ans ^= (1ll << idx); } } cout << ans; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:43:7: 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:45:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x), pr[i] = pr[i - 1] + x;
   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...