Submission #25009

#TimeUsernameProblemLanguageResultExecution timeMemory
25009kdh9949Bali Sculptures (APIO15_sculpture)C++14
0 / 100
0 ms3620 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; int n, a, b; ll s[2010], dp[101][2010], ans = inf; int main(){ scanf("%d%d%d", &n, &a, &b); for(int i = 1; i <= n; i++){ scanf("%lld", s + i); s[i] += s[i - 1]; } if(n <= 100){ fill(dp[0] + 1, dp[0] + n + 1, inf); for(int i = 1; i <= b; i++){ for(int j = i; j <= n; j++){ dp[i][j] = inf; for(int k = i - 1; k < j; k++){ dp[i][j] = min(dp[i][j], dp[i - 1][k] | (s[j] - s[k])); } } } for(int i = a; i <= b; i++) ans = min(ans, dp[i][n]); printf("%lld\n", ans); } else{ for(int i = 1; i <= n; i++){ dp[0][i] = inf; for(int j = 0; j < i; j++){ dp[0][i] = min(dp[0][i], dp[0][j] | (s[i] - s[j])); } } printf("%lld\n", dp[0][n]); } }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:10:29: 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:11:51: 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("%lld", s + i); s[i] += s[i - 1]; }
                                                   ^
#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...