제출 #660381

#제출 시각아이디문제언어결과실행 시간메모리
660381evenvalue비스킷 담기 (IOI20_biscuits)C++17
0 / 100
1094 ms340 KiB
#include "biscuits.h" #include <bits/stdc++.h> using namespace std; template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>; template<typename T> using max_heap = priority_queue<T, vector<T>, less<T>>; using int64 = long long; using ld = long double; constexpr int kInf = 1e9 + 10; constexpr int64 kInf64 = 1e15 + 10; constexpr int kMod = 1e9 + 7; constexpr int kBits = 17; string to_bin(const int64 y) { string ans; for (int bit = 0; bit < kBits; bit++) { ans += (y & (1LL << bit)) ? '1' : '0'; } return ans; } int64 count_tastiness(int64 x, vector<int64> a) { while (a.back() == 0) a.pop_back(); while (a.size() < kBits) a.push_back(0); const int n = a.size(); int64 total = 0; for (int i = 0; i < n; i++) { total += (a[i] << i); } const int64 ymax = total / x; auto check = [&](vector<int64> &biscuits, const string &y) -> bool { int64 need = 0; for (int i = y.size() - 1; i >= 0; i--) { if (y[i] == '1') need++; const int64 dec = min(need, biscuits[i]); biscuits[i] -= dec; need -= dec; need *= 2; } return not need; }; int64 ans = 0; for (int y = 0; y <= ymax; y++) { auto biscuits = a; const string bin = to_bin(y); bool flag = true; for (int bag = 0; bag < x; bag++) { flag &= check(biscuits, bin); } ans += flag; } return ans; }
#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...