Submission #40901

#TimeUsernameProblemLanguageResultExecution timeMemory
40901IvanCBali Sculptures (APIO15_sculpture)C++14
16 / 100
131 ms37992 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 101; const int MAXOR = 4096; int dp[MAXN][MAXN][MAXOR],best,N,A,B,soma[MAXN]; int calc(int a,int b){return soma[b] - soma[a-1];} void solve(int pos,int resta,int curOr){ if(dp[pos][resta][curOr]) return; dp[pos][resta][curOr] = 1; if(pos == N + 1){ if(resta != 0) return; best = min(best,curOr); return; } if(resta == 0) return; for(int quebra = pos;quebra<=N;quebra++){ solve(quebra+1,resta - 1,curOr | calc(pos,quebra)); } } int main(){ scanf("%d %d %d",&N,&A,&B); for(int i = 1;i<=N;i++){ scanf("%d",&soma[i]); soma[i] += soma[i-1]; } best = MAXOR; for(int i = A;i<=B;i++) solve(1,i,0); printf("%d\n",best); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:21:28: 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:23:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&soma[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...