이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <iostream>
#include <map>
using namespace std;
const int kMaxK = 127;
typedef long long int64;
typedef __int128_t int128;
#define DEBUG if(0)
long long count_tastiness(int64 x, std::vector<int64> a) {
a.resize(kMaxK, 0);
int128 target_carry = 0;
int128 p = 1;
for (int i = 0; i < (int)a.size(); i += 1) {
target_carry += a[i] * p;
p *= 2;
}
map<int128, int64> old = { {0, 1} };
int64 ans = 1;
int128 global_carry = 0;
p = 1;
for (int i = 0; i < kMaxK; i += 1) {
global_carry += a[i] * p;
vector<pair<int128, int64>> new_additions;
for (auto itr = old.rbegin(); itr != old.rend(); itr++) {
int128 carry = itr->first;
int64 num = itr->second;
if (global_carry + carry >= x * p) {
DEBUG cerr << "Add + for " << i << '\n';
ans += num;
new_additions.emplace_back(carry - x * p, num);
}
}
for (auto& itr : new_additions) {
old[itr.first] += itr.second;
}
p *= 2;
if (target_carry == global_carry) {
break;
}
}
return ans;
}
# | 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... |