# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72280 | 2018-08-26T06:44:07 Z | um..(#2163, grape, sssyyy, arpiel0610) | Gorgeous Pill (FXCUP3_gorgeous) | C++14 | 4 ms | 376 KB |
#include <stdio.h> int c[300001]; int d[300001]; int chk[300001] = { 0 }; int n; long long max = 0; void bfs(int node, int cnt, long long sum) { if (cnt == n) { if (max < sum) max = sum; return; } int tmpn = node; int tmp1 = node - 1; int tmp2 = node + 1; while(tmp1 >=0){ if (chk[tmp1] == 0) { int num = 0; if (cnt + 1 == c[tmp1]) num += d[tmp1]; chk[tmp1] = 1; bfs(tmp1, cnt + 1, sum + num); chk[tmp1] = 0; break; } tmp1--; }// ���� ���� while (tmp2 >= 0) { if (chk[tmp2] == 0) { int num = 0; if (cnt + 1 == c[tmp2]) num += d[tmp2]; chk[tmp2] = 1; bfs(tmp2, cnt + 1, sum + num); chk[tmp2] = 0; break; } tmp2++; }// ������ ���� } int main() { int i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &c[i]); for (i = 0; i < n; i++) scanf("%d", &d[i]); for (i = 0; i < n; i++) { chk[i] = 1; int in = 0; if (c[i] == 1) in = d[i]; bfs(i, 1, in); chk[i] = 0; printf("%lld ", max); max = 0; } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 4 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 4 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 4 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |