이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// ~ Be Name Khoda ~ //
#include "biscuits.h"
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops,Ofast")
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int maxn = 1e6 + 10;
const int maxn5 = 5e5 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 1e18;
ll x, sum[100], a[100];
vector <ll> solve(int i, vector <ll> need){
vector <ll> av;
if(i == -1){
av.resize(int(need.size()) + 1);
fill(all(av), 1);
return av;
}
for(int j = 0; j < need.size(); j++)
need[j] = max(need[j], 0ll);
need.pb(0);
//cout << i << ' ' << need.size() << ' ' << sum[i] << endl;
for(auto y : need){
if(sum[i] - y >= (1ll << i) * x)
av.pb(y + (x - a[i]) * (1ll << i));
else
av.pb(y - a[i] * (1ll << i));
}
av = solve(i - 1, av);
for(int j = 0; j < int(av.size()) - 1; j++){
if(sum[i] - need[j] >= (1ll << i) * x)
av[j] += av.back();
//cout << "* " << i << ' ' << j << ' ' << need[j] << ' ' << av[j] << endl;
}
av.pop_back();
return av;
}
long long count_tastiness(long long xx, std::vector<long long> aa) {
x = xx;
memset(a, 0, sizeof a);
memset(sum, 0, sizeof sum);
for(int i = 0; i < int(aa.size()); i++){
a[i] = aa[i];
sum[i] = a[i] * (1ll << i);
if(i)
sum[i] += sum[i - 1];
}
for(int i = aa.size(); i < 60; i++)
sum[i] = sum[i - 1];
vector <ll> av;
av = solve(59, av);
//cout << "hey " << av.size() << endl;
return av.back();
}
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'std::vector<long long int> solve(int, std::vector<long long int>)':
biscuits.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int j = 0; j < need.size(); j++)
| ~~^~~~~~~~~~~~~
# | 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... |