답안 #72289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72289 2018-08-26T06:51:17 Z um..(#2163, grape, sssyyy, arpiel0610) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++14
0 / 100
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

gorgeous.cpp: In function 'void bfs(int, int, long long int)':
gorgeous.cpp:13:6: warning: unused variable 'tmpn' [-Wunused-variable]
  int tmpn = node;
      ^~~~
gorgeous.cpp: In function 'int main()':
gorgeous.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:43:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 0; i < n; i++) scanf("%d", &c[i]);
                          ~~~~~^~~~~~~~~~~~~
gorgeous.cpp:44:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 0; i < n; i++) scanf("%d", &d[i]);
                          ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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