Submission #109441

#TimeUsernameProblemLanguageResultExecution timeMemory
109441dupreezBali Sculptures (APIO15_sculpture)C++14
21 / 100
113 ms28636 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <vector> #include <deque> #include <climits> #define scanf scanf_s #define mk make_pair #define pb push_back using namespace std; typedef long long int ll; typedef pair<ll, ll> pos; const ll MOD = 1000000007, N = 2010; ll min2(ll v1, ll v2) { if (v1 == -1)return v2; if (v2 == -1)return v1; return min(v1, v2); } int dp[110][1 << 15],a[110],n,av,bv; int main() { memset(dp, -1, sizeof(dp)); dp[0][0] = 0; cin >> n >> av >> bv; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } for (int i = 0; i < n; i++) { for (int i2 = i + 1; i2 <= n; i2++) { int v1 = a[i2] - a[i]; for (int s = 0; s < (1 << 15); s++) { if (dp[i][s] == -1)continue; dp[i2][s | v1] = min2(dp[i2][s | v1], dp[i][s] + 1); } } } for (int s = 0; s < (1 << 15); s++) { if (dp[n][s] != -1 && dp[n][s] <= bv) { cout << s << endl; break; } } 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...