Submission #566526

#TimeUsernameProblemLanguageResultExecution timeMemory
566526ac2huBali Sculptures (APIO15_sculpture)C++14
21 / 100
1087 ms3008 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){ for(auto it = begin();it!=end();++it){ auto [e, val] = *it; if(((e&n) == e) && temp >= val)return; } 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); } } } } } deb(dp[n]); cout << (*dp[n].begin()).first << "\n"; }

Compilation message (stderr)

sculpture.cpp: In member function 'void bag::add(long long int, long long int)':
sculpture.cpp:12:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   12 |             auto [e, val] = *it;
      |                  ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:31:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |                 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...