답안 #72229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72229 2018-08-26T06:11:15 Z 마릴린 희정(#2180, gs14004, ho94949) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++14
51 / 100
16 ms 9560 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 1050;

lint dp[MAXN][MAXN];
int n, a[MAXN], b[MAXN];

lint f(int s, int e){
	if(~dp[s][e]) return dp[s][e];
	lint ret = 0;
	if(s > 1){
		ret = max(ret, f(s - 1, e) + (a[s - 1] == (e - s + 2) ? b[s - 1] : 0));
	}
	if(e < n){
		ret = max(ret, f(s, e + 1) + (a[e + 1] == (e - s + 2) ? b[e + 1] : 0));
	}
	return dp[s][e] = ret;
}

int main(){
	scanf("%d",&n);
	if(n > 1000 ) return 0;
	for(int i=1; i<=n; i++) scanf("%d",&a[i]);
	for(int i=1; i<=n; i++) scanf("%d",&b[i]);
	memset(dp, -1, sizeof(dp));
	for(int i=1; i<=n; i++){
		lint ans = f(i, i);
		if(a[i] == 1) ans += b[i];
		printf("%lld ", ans);
	}
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
gorgeous.cpp:26:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d",&a[i]);
                          ~~~~~^~~~~~~~~~~~
gorgeous.cpp:27:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d",&b[i]);
                          ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8952 KB Output is correct
2 Correct 10 ms 8952 KB Output is correct
3 Correct 8 ms 9096 KB Output is correct
4 Correct 9 ms 9096 KB Output is correct
5 Correct 9 ms 9236 KB Output is correct
6 Correct 10 ms 9332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8952 KB Output is correct
2 Correct 10 ms 8952 KB Output is correct
3 Correct 8 ms 9096 KB Output is correct
4 Correct 9 ms 9096 KB Output is correct
5 Correct 9 ms 9236 KB Output is correct
6 Correct 10 ms 9332 KB Output is correct
7 Correct 9 ms 9332 KB Output is correct
8 Correct 9 ms 9332 KB Output is correct
9 Correct 10 ms 9332 KB Output is correct
10 Correct 10 ms 9332 KB Output is correct
11 Correct 12 ms 9340 KB Output is correct
12 Correct 16 ms 9368 KB Output is correct
13 Correct 15 ms 9388 KB Output is correct
14 Correct 15 ms 9524 KB Output is correct
15 Correct 14 ms 9560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8952 KB Output is correct
2 Correct 10 ms 8952 KB Output is correct
3 Correct 8 ms 9096 KB Output is correct
4 Correct 9 ms 9096 KB Output is correct
5 Correct 9 ms 9236 KB Output is correct
6 Correct 10 ms 9332 KB Output is correct
7 Correct 9 ms 9332 KB Output is correct
8 Correct 9 ms 9332 KB Output is correct
9 Correct 10 ms 9332 KB Output is correct
10 Correct 10 ms 9332 KB Output is correct
11 Correct 12 ms 9340 KB Output is correct
12 Correct 16 ms 9368 KB Output is correct
13 Correct 15 ms 9388 KB Output is correct
14 Correct 15 ms 9524 KB Output is correct
15 Correct 14 ms 9560 KB Output is correct
16 Incorrect 2 ms 9560 KB Output isn't correct
17 Halted 0 ms 0 KB -