# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72289 | 2018-08-26T06:51:17 Z | um..(#2163, grape, sssyyy, arpiel0610) | 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) | C++14 | 4 ms | 500 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+1) { 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 <= n) { 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 500 KB | Output is correct |
6 | Incorrect | 4 ms | 500 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 500 KB | Output is correct |
6 | Incorrect | 4 ms | 500 KB | Output isn't correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 500 KB | Output is correct |
5 | Correct | 4 ms | 500 KB | Output is correct |
6 | Incorrect | 4 ms | 500 KB | Output isn't correct |