Submission #699334

#TimeUsernameProblemLanguageResultExecution timeMemory
699334CatalinTBali Sculptures (APIO15_sculpture)C++17
50 / 100
77 ms364 KiB
#include <vector> #include <iostream> #include <cassert> #include <algorithm> #include <numeric> #include <iostream> #include <set> #include <map> #include <string> #include <unordered_map> #include <functional> #include <bitset> #include <sstream> using namespace std; using int64 = long long; int N, A, B; vector<int> X; int64 S; bool can_do(int64 mask, int64 care) { vector<int> dp(N + 1, (1<<30)); dp[0] = 0; for (int i = 1; i <= N; i++) { int64 cur = 0; int64 ored = 0; for (int j = i; j >= 1; j--) { cur += X[j]; if (((cur & care) | mask) == mask) { if (dp[i] > dp[j-1] + 1) { dp[i] = dp[j-1] + 1; } } } } return dp[N] <= B; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N >> A >> B; X.resize(N + 1); for (int i = 1; i <= N; i++) { cin >> X[i]; S += X[i]; } const int max_bit = 42; int64 mask = 0; int64 care = 0; for (int i = max_bit; i >= 0; i--) { int64 bit = (1LL<<i); care |= bit; if (can_do(mask, care)) { } else { mask |= bit; } } cout << mask << "\n"; return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'bool can_do(int64, int64)':
sculpture.cpp:30:15: warning: unused variable 'ored' [-Wunused-variable]
   30 |         int64 ored = 0;
      |               ^~~~
#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...