이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "biscuits.h"
using namespace std;
typedef long long ll;
vector<map<ll, ll>> dp;
ll numWays(const ll &n, const ll &m, const ll &mxN, const ll &x, const vector<ll> &a) {
if (n == mxN) return m/x + 1;
if (dp[n][m]) return dp[n][m];
ll res = numWays(n+1, a[n+1] + m/2, mxN, x, a);
if (m >= x) {
res += numWays(n+1, a[n+1] + (m-x)/2, mxN, x, a);
}
return dp[n][m] = res;
}
ll count_tastiness(ll x, vector<ll> a) {
for (int i = 0; i < a.size(); i++) {
ll transfer = max(0ll, (a[i]-x) / (2*x));
if (transfer > 0) {
if (i+1 >= a.size()) a.push_back(x*transfer);
else a[i+1] += x*transfer;
a[i] -= 2*x*transfer;
}
}
ll n = a.size();
ll m = 6*x;
dp = vector<map<ll, ll>>(n-1);
ll res = numWays(0, a[0], n-1, x, a);
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for (int i = 0; i < a.size(); i++) {
| ~~^~~~~~~~~~
biscuits.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | if (i+1 >= a.size()) a.push_back(x*transfer);
| ~~~~^~~~~~~~~~~
biscuits.cpp:31:8: warning: unused variable 'm' [-Wunused-variable]
31 | ll m = 6*x;
| ^
# | 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... |