답안 #72060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72060 2018-08-26T05:04:46 Z um..(#2163, grape, sssyyy, arpiel0610) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++14
0 / 100
2 ms 248 KB
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<string>
#define ll long long

using namespace std;

long long c[300005];
long long d[300005];
long long ans[300005];
int n;
int anss = 0;
void go(int l, int r, int now, int th, int m) {
	
	if (c[now] == th) m += d[now];
	if(l>0) go(l - 1, r, l, th + 1, m);
	if(r<n+1) go(l, r + 1, r, th + 1, m);
	if (l == 0 && r == n + 1) {
		if (anss < m) anss= m;
	}
	return;
}

int main()
{

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &c[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &d[i]);
	}

	for (int i = 1; i <= n; i++) {
		int l = i - 1, r = n - i;
		anss = 0;
		go(i - 1, i+1, i, 1, 0);
		ans[i] = anss;
	}

	printf("%lld", ans[1]);
	for (int i = 2; i <= n; i++) printf(" %lld", ans[i]);
	printf("\n");

	printf("%d", 15000000000);

	return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:41:7: warning: unused variable 'l' [-Wunused-variable]
   int l = i - 1, r = n - i;
       ^
gorgeous.cpp:41:18: warning: unused variable 'r' [-Wunused-variable]
   int l = i - 1, r = n - i;
                  ^
gorgeous.cpp:51:26: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
  printf("%d", 15000000000);
                          ^
gorgeous.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &c[i]);
   ~~~~~^~~~~~~~~~~~~~~
gorgeous.cpp:37:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &d[i]);
   ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -