Submission #991684

#TimeUsernameProblemLanguageResultExecution timeMemory
991684_rain_Bali Sculptures (APIO15_sculpture)C++14
9 / 100
68 ms604 KiB
/** author : Knquin_ **/ #include<bits/stdc++.h> using namespace std; using i64 = long long; using ui64 = unsigned long long; #define MASK(x) ((i64)(1) << (x)) #define BIT(mask , x) (((mask) >> (x)) & (1)) #define sz(x) (x).size() #define all(x) (x).begin() , (x).end() #define FOR(i ,a , b) for (int i = (a); i <= (b); ++i) #define FORD(i , a , b) for (int i = (b); i >= (a); --i) #define REP(i , a , b) for (int i = (a); i < (b); ++i) #define REPD(i , a , b) for (int i = (b) - 1 ; i >= (a); --i) mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); template<class T> bool maximize(T &a , T b) {if (a < b) return a = b , true; else return false;} template<class T> bool minimize(T &a , T b) {if (a > b) return a = b , true; else return false;} template<class T> T gcd(T x , T y) {while (y) swap(y , x %= y); return x;} template<class T> T lcm(T x , T y) {return (x * y) / gcd(x , y);} template <class T> void compress(vector<T> &a) { sort(a.begin() , a.end()); a.resize(unique(a.begin() , a.end()) - a.begin()); return; } template<class T> void printArr(T& container , string separator = "" , string finish = "\n") { for (auto& item : container) cout << item << separator; cout << finish; } const int maxn = 20; int n , A , B; i64 a[maxn + 2]; int32_t main() { iostream::sync_with_stdio(false); cin.tie(0); const string name = "main"; if (fopen((name + ".inp").c_str() , "r")) { (void)!freopen((name + ".inp").c_str() , "r" , stdin); (void)!freopen((name + ".ans").c_str() , "w+", stdout); } cin >> n >> A >> B; if (n > 20) return 0; REP(i , 0 , n) cin >> a[i]; i64 answer = (i64)1e18; vector<int> bucket; FOR(mask , 0 , MASK(n) - 1) { if (__builtin_popcount(mask) == 0) continue; int used = 0 , last = -1 ; i64 cur = 0 , sum = 0; REP(i , 0 , n) { if (BIT(mask ,i) != last) { ++used; sum |= cur; cur = a[i]; last = BIT(mask , i); } else cur += a[i]; } sum |= cur; if (A <= used && used <= B) { if (minimize(answer , sum)) { bucket.clear(); REP(i , 0 , n) bucket.push_back(BIT(mask , i)); } } } cout << answer << '\n'; }
#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...