답안 #72315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72315 2018-08-26T07:01:45 Z um..(#2163, grape, sssyyy, arpiel0610) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++14
12 / 100
1500 ms 468 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 < 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 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 392 KB Output is correct
6 Correct 3 ms 408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 392 KB Output is correct
6 Correct 3 ms 408 KB Output is correct
7 Execution timed out 1566 ms 468 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 392 KB Output is correct
5 Correct 3 ms 392 KB Output is correct
6 Correct 3 ms 408 KB Output is correct
7 Execution timed out 1566 ms 468 KB Time limit exceeded
8 Halted 0 ms 0 KB -