답안 #72298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72298 2018-08-26T06:54:42 Z 이시대의진정한망겜스타투(#2267, cki86201, ainta) 놀이터에 떨어진 이상한 약 (FXCUP3_gorgeous) C++14
51 / 100
12 ms 7580 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;

int N, C[1010], D[1010];
ll dp[1010][1010];

int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++) scanf("%d", C + i);
	for(int i=1;i<=N;i++) scanf("%d", D + i);
	for(int i=N-1;i>=0;i--) {
		for(int j=1;j+i<=N;j++) {
			int lv = j, rv = j + i;
			dp[lv][rv] = 0;
			if(lv != 1) dp[lv][rv] = max(dp[lv][rv], dp[lv - 1][rv] + (C[lv-1] == rv - lv + 2 ? D[lv-1] : 0));
			if(rv != N) dp[lv][rv] = max(dp[lv][rv], dp[lv][rv + 1] + (C[rv+1] == rv - lv + 2 ? D[rv+1] : 0));
		}
	}
	for(int i=1;i<=N;i++) if(C[i] == 1) dp[i][i] += D[i];
	for(int i=1;i<=N;i++) printf("%lld ", dp[i][i]); puts("");
	return 0;
}

Compilation message

gorgeous.cpp: In function 'int main()':
gorgeous.cpp:48:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int i=1;i<=N;i++) printf("%lld ", dp[i][i]); puts("");
  ^~~
gorgeous.cpp:48:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int i=1;i<=N;i++) printf("%lld ", dp[i][i]); puts("");
                                                   ^~~~
gorgeous.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
gorgeous.cpp:37:29: 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", C + i);
                        ~~~~~^~~~~~~~~~~~~
gorgeous.cpp:38:29: 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", D + i);
                        ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 556 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 556 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 3 ms 928 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 2540 KB Output is correct
11 Correct 8 ms 5868 KB Output is correct
12 Correct 12 ms 7036 KB Output is correct
13 Correct 11 ms 7548 KB Output is correct
14 Correct 11 ms 7564 KB Output is correct
15 Correct 11 ms 7580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 3 ms 556 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 3 ms 556 KB Output is correct
6 Correct 2 ms 556 KB Output is correct
7 Correct 2 ms 624 KB Output is correct
8 Correct 3 ms 928 KB Output is correct
9 Correct 3 ms 1004 KB Output is correct
10 Correct 4 ms 2540 KB Output is correct
11 Correct 8 ms 5868 KB Output is correct
12 Correct 12 ms 7036 KB Output is correct
13 Correct 11 ms 7548 KB Output is correct
14 Correct 11 ms 7564 KB Output is correct
15 Correct 11 ms 7580 KB Output is correct
16 Execution timed out 4 ms 7580 KB Time limit exceeded (wall clock)
17 Halted 0 ms 0 KB -