Submission #72275

# Submission time Handle Problem Language Result Execution time Memory
72275 2018-08-26T06:40:33 Z um..(#2163, grape, sssyyy, arpiel0610) Gorgeous Pill (FXCUP3_gorgeous) C++14
0 / 100
3 ms 488 KB
#include <stdio.h>
int c[300001];
int d[300001];
int chk[300001] = { 0 };
int n, max = 0;
void bfs(int node, int cnt, int 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("%d ", max);
		max = 0;
	}
	printf("\n");
	return 0;
}

Compilation message

gorgeous.cpp: In function 'void bfs(int, int, int)':
gorgeous.cpp:12:6: warning: unused variable 'tmpn' [-Wunused-variable]
  int tmpn = node;
      ^~~~
gorgeous.cpp: In function 'int main()':
gorgeous.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:42: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: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", &d[i]);
                          ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 3 ms 488 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 3 ms 488 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 3 ms 488 KB Output isn't correct
3 Halted 0 ms 0 KB -