# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
309469 | Ruxandra985 | 비스킷 담기 (IOI20_biscuits) | C++14 | 1105 ms | 175992 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
map <long long , long long> mp[61];
long long s[61];
long long x2;
long long rec (int bit , long long nr){
long long sum = 0;
if (bit < 0)
return 1;
nr = min(nr , s[bit] / x2);
if (mp[bit].find(nr) != mp[bit].end()){ /// exista deja
return mp[bit][nr];
}
if ((1LL << bit) <= nr){ /// nr tine de s[i], de asta, asta ins ca poate fi bitul 1
sum += rec(bit - 1 , nr - (1LL << bit));
}
/// altfel pui bitul 0 aici
sum += rec (bit - 1 , nr);
mp[bit][nr] = sum;
return sum;
}
long long count_tastiness(long long x, vector<long long> a) {
int i;
x2 = x;
for (i = 0 ; i <= 60 ; i++){
mp[i].clear();
s[i] = 0;
}
s[60] = 0;
for (i = 0 ; i <= 60 ; i++){
if (i < a.size())
s[i] += a[i] * (1LL << i);
if (i)
s[i] += s[i - 1];
}
/// s[i] / x e un fel de maxim posibil sa ai pana la i
return rec(60 , min( s[60] / x , (1LL << 60) ) );
}
Compilation message (stderr)
# | 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... |