답안 #58158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
58158 2018-07-17T04:40:11 Z 윤교준(#1690) Candies (JOI18_candies) C++11
8 / 100
341 ms 66128 KB
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;

const int MAXN = 2005;

ll d[MAXN][MAXN];

ll A[MAXN];

int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i];

	for(int i = 0; i <= N; i++) fill(d[i], d[i]+N+1, -INFLL);
	for(int i = 0; i <= N; i++) d[i][0] = 0;
	for(int i = 1; i <= N; i++) d[i][1] = A[i];

	for(int i = 2; i <= N; i++) for(int j = 1; j <= N; j++) {
		upmax(d[i][j], d[i-1][j]);
		if(1 < i) upmax(d[i][j], d[i-2][j]);
		if(1 < i) upmax(d[i][j], d[i-2][j-1] + A[i]);
	}

	for(int i = 1; i <= (N+1)/2; i++)
		printf("%lld\n", d[N][i]);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 31736 KB Output is correct
2 Correct 41 ms 31992 KB Output is correct
3 Correct 40 ms 31992 KB Output is correct
4 Correct 45 ms 31992 KB Output is correct
5 Correct 42 ms 32064 KB Output is correct
6 Correct 38 ms 32064 KB Output is correct
7 Correct 38 ms 32064 KB Output is correct
8 Correct 36 ms 32156 KB Output is correct
9 Correct 38 ms 32156 KB Output is correct
10 Correct 51 ms 32156 KB Output is correct
11 Correct 40 ms 32216 KB Output is correct
12 Correct 39 ms 32216 KB Output is correct
13 Correct 50 ms 32332 KB Output is correct
14 Correct 48 ms 32340 KB Output is correct
15 Correct 48 ms 32340 KB Output is correct
16 Correct 47 ms 32340 KB Output is correct
17 Correct 47 ms 32340 KB Output is correct
18 Correct 47 ms 32464 KB Output is correct
19 Correct 42 ms 32464 KB Output is correct
20 Correct 40 ms 32464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 31736 KB Output is correct
2 Correct 41 ms 31992 KB Output is correct
3 Correct 40 ms 31992 KB Output is correct
4 Correct 45 ms 31992 KB Output is correct
5 Correct 42 ms 32064 KB Output is correct
6 Correct 38 ms 32064 KB Output is correct
7 Correct 38 ms 32064 KB Output is correct
8 Correct 36 ms 32156 KB Output is correct
9 Correct 38 ms 32156 KB Output is correct
10 Correct 51 ms 32156 KB Output is correct
11 Correct 40 ms 32216 KB Output is correct
12 Correct 39 ms 32216 KB Output is correct
13 Correct 50 ms 32332 KB Output is correct
14 Correct 48 ms 32340 KB Output is correct
15 Correct 48 ms 32340 KB Output is correct
16 Correct 47 ms 32340 KB Output is correct
17 Correct 47 ms 32340 KB Output is correct
18 Correct 47 ms 32464 KB Output is correct
19 Correct 42 ms 32464 KB Output is correct
20 Correct 40 ms 32464 KB Output is correct
21 Runtime error 341 ms 66128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Halted 0 ms 0 KB -