Submission #319724

#TimeUsernameProblemLanguageResultExecution timeMemory
319724TeaTimeBali Sculptures (APIO15_sculpture)C++17
71 / 100
1098 ms1252 KiB
#include<iostream> #include<vector> #include <bitset> using namespace std; typedef long long ll; typedef long double ld; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); const ll SZ = 3000; vector<ll> vec; ll n, a, b; ll dp[SZ]; bitset<SZ> dp2[SZ]; ll sol(bool fl) { ll curMsk = (1ll << 37) - 1; for (ll bt = 36; bt >= 0; bt--) { ll msk = curMsk ^ (1ll << bt); for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) dp2[i][j] = 0; } dp2[0][0] = 1; for (int i = 0; i < n; i++) { ll s = 0; for (int j = i; j >= 0; j--) { s += vec[j]; if ((msk | s) == msk) { dp2[i + 1] |= (dp2[j] << 1); } } } bool k = 0; for (int i = a; i <= b; i++) { if (dp2[n][i]) { k = 1; } } if (k) { curMsk = msk; } } return curMsk; } int main() { fastInp; cin >> n >> a >> b; vec.resize(n); for (auto &cur : vec) cin >> cur; if (a == 1) { cout << sol(0); } else { cout << sol(0); } return 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...