Submission #96502

#TimeUsernameProblemLanguageResultExecution timeMemory
96502SmelskiyBali Sculptures (APIO15_sculpture)C++14
50 / 100
117 ms504 KiB
#include <bits/stdc++.h> using namespace std; int n; long long d[2005]; int a, b; bool can(long long mask) { int dp[2005]; for (int i = 0; i <= n; i++) { dp[i] = 100000; } dp[0] = 0; for (int i = 0; i < n; i++) { if (dp[i] < 100000) { long long cur_sum = 0; for (int j = i; j < n; j++) { cur_sum += d[j]; if ((cur_sum & mask) == 0) { dp[j+1] = min(dp[j+1], dp[i] + 1); } } } } return dp[n] <= b; } int main() { // freopen("sculpture.in", "r", stdin); // freopen("sculpture.out", "w", stdout); scanf("%d %d %d", &n, &a, &b); for (int i = 0; i < n; i++) { scanf("%lld", &d[i]); } long long cur_mask = 0; for (int i = 60; i >= 0; --i) { if (can(cur_mask | (1LL<<i))) { cur_mask = cur_mask | (1LL<<i); } } printf("%lld\n", (1LL<<61) -1 - cur_mask); }

Compilation message (stderr)

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