Submission #566519

#TimeUsernameProblemLanguageResultExecution timeMemory
566519ac2huBali Sculptures (APIO15_sculpture)C++14
21 / 100
1079 ms61756 KiB
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else 
#define deb(x...)
#endif
using namespace std;
#define int long long 
struct bag : set<pair<int,int>>{
    void add(int n, int temp){
        insert({n, temp});
    }
};
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n, a, b;cin >> n >> a >> b;
    vector<int> Y(n);
    for(auto &e : Y)cin >> e;
    bag dp[n + 1];
    dp[0].add(0, 0);
    for(int i = 1;i<=n;i++){
        int tsum = 0;
        for(int j = i;j>=1;j--){
            tsum += Y[j - 1];
            if(dp[j - 1].size() != 0){
                for(auto [e, val] : dp[j - 1]){
                    if(val < b){
                        dp[i].add(e|tsum, val + 1);
                    }
                }
            }
        }
    }
    cout << (*dp[n].begin()).first << "\n";
}

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:27:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   27 |                 for(auto [e, val] : dp[j - 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...