답안 #73828

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73828 2018-08-29T05:37:15 Z 김세빈(#2276) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++11
51 / 100
42 ms 16776 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll dp[1010][1010];
ll C[1010], D[1010];
ll n;

int main()
{
	ll i, j;
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld", C + i);
	}
	
	for(i=1; i<=n; i++){
		scanf("%lld", D + i);
	}
	
	for(i=1; i<=n; i++){
		for(j=n; j>=i; j--){
			if(i > 1) dp[i][j] = max(dp[i][j], dp[i - 1][j] + (C[i - 1] == j - i + 2) * D[i - 1]);
			if(j < n) dp[i][j] = max(dp[i][j], dp[i][j + 1] + (C[j + 1] == j - i + 2) * D[j + 1]);
		}
	}

	for(i=1; i<=n; i++){
		printf("%lld ", dp[i][i] + (C[i] == 1) * D[i]);
	}
		
	printf("\n");
	
	return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
gorgeous.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", C + i);
   ~~~~~^~~~~~~~~~~~~~~
gorgeous.cpp:22: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 Correct 4 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 4 ms 484 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 4 ms 484 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 976 KB Output is correct
9 Correct 3 ms 976 KB Output is correct
10 Correct 6 ms 2512 KB Output is correct
11 Correct 11 ms 5764 KB Output is correct
12 Correct 14 ms 7008 KB Output is correct
13 Correct 16 ms 7684 KB Output is correct
14 Correct 15 ms 7684 KB Output is correct
15 Correct 13 ms 7684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 248 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 4 ms 484 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 976 KB Output is correct
9 Correct 3 ms 976 KB Output is correct
10 Correct 6 ms 2512 KB Output is correct
11 Correct 11 ms 5764 KB Output is correct
12 Correct 14 ms 7008 KB Output is correct
13 Correct 16 ms 7684 KB Output is correct
14 Correct 15 ms 7684 KB Output is correct
15 Correct 13 ms 7684 KB Output is correct
16 Runtime error 42 ms 16776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -