# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20129 | hongjun7 | 생일수 I (GA4_birthday1) | C++14 | 692 ms | 16708 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 <stdio.h>
#define MAXN 1000000
int T, n, d[MAXN + 5], x[3] = { 3,5,8 }, v[MAXN + 5][3];
int main() {
for (int i = 1; i <= MAXN; i++) d[i] = MAXN;
for (int i = 0; i < 3; i++) {
for (int j = x[i]; j <= MAXN; j++) {
if (d[j - x[i]] + 1 < d[j]) {
d[j] = d[j - x[i]] + 1;
for (int k = 0; k < 3; k++) v[j][k] = v[j - x[i]][k];
v[j][i]++;
}
else if (d[j - x[i]] + 1 == d[j]) {
bool ok = 1;
for (int k = 0; k < 3; k++) {
int aa = v[j - x[i]][k];
if (k == i) aa++;
int bb = v[j][k];
if (aa < bb) { ok = 0; break; }
if (aa > bb) break;
}
if (ok) {
for (int k = 0; k < 3; k++) v[j][k] = v[j - x[i]][k];
v[j][i]++;
}
}
}
}
for (scanf("%d", &T); T--; ) {
scanf("%d", &n);
# | 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... |