이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "biscuits.h"
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#ifdef DEBUG
auto& operator<<(auto &os, const pair<auto,auto> &p) {
return os<<"("<<p.first<<", "<<p.second<<")";
}
auto& operator<<(auto &os, const auto &v) {
os<<"{";
for(auto it=begin(v);it!=end(v);++it) {
if(it != begin(v)) os<<", ";
os<<(*it);
}
return os<<"}";
}
void dbg_out(auto... x) {
((cerr<<' '<<x), ...) << endl;
}
#define dbg(x...) cerr<<"("<<#x<<"):", dbg_out(x);
#else
#define dbg(...)
#endif
typedef vector<ll> vll;
const ll inf = ll(1e18) + 7;
ll k;
ll num(ll val, vll a) {
if(val == 0) return inf;
if(val >= (1LL<<k)) return 0;
vll needed(k, 0);
rep(i,0,k)
if((val>>ll(i)) & 1LL)
needed[i] = 1;
ll result = 0;
while(true) {
int mini = -1;
rep(i,0,k) {
if(needed[i] == 0) continue;
if(mini == -1 || (a[i] / needed[i]) < (a[mini] / needed[mini]))
mini = i;
}
if(mini == -1) break;
ll res = a[mini] / needed[mini];
result += res;
if(mini == 0) break;
rep(i,0,k) a[i] -= res * needed[i];
needed[mini-1] += needed[mini] * 2;
needed[mini] = 0;
}
return result;
}
ll count_tastiness(ll x, vll a) {
k = sz(a);
ll res = 1;
rep(i,0,k) {
res += a[i] * (1LL<<ll(i));
}
// ll res = 0;
// rep(i,0,100007) {
// bool poss = num(i, a) >= x;
// if(poss) dbg(i);
// res += poss;
// }
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |