회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
2
채점 현황
랭킹
게시판
그룹
더 보기
재채점 기록
블로그
강의
실험실
도움말
BOJ Stack
BOJ Book
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
요리강좌 14869 질문입니다.
14869번 - 요리 강좌
yomyom0824
5년 전
0
탑다운으로 풀었는데요.
어느 부분이 문제가 있는지 도저히 모르겠습니다 ㅠㅠ 도와주세요.
#include <algorithm> #include <assert.h> #include <complex> #include <ctype.h> #include <functional> #include <iostream> #include <limits.h> #include <locale.h> #include <map> #include <math.h> #include <queue> #include <set> #include <iostream> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <cmath> #include <vector> #include <deque> #include <map> #include <bitset> #define ARRAY_SIZE(x) ( sizeof((x))/sizeof((x)[0]) ) #define LOOP(x,s,e) for(int x = s; x < e; ++x) #define LOOP_(x,s,e) for(int x = s; x >= e; --x) #define LOOP_EQ(x,s,e) for(int x = s; x <= e; ++x) #define INF 2e9 typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef unsigned int ui; typedef unsigned short us; #pragma warning(disable:4996) using namespace std; int n, m, s, e, t; int info[3001]; int price[3001][3001]; int cache[3001][3001]; int find1(int prev_school, int cur_subject, int num_of_continue) { if (cur_subject == m) return 0; int& ret = cache[prev_school][cur_subject]; if (ret != -1) return ret; ret = 1234567890; if (num_of_continue < s) { ret = min(ret, find1(prev_school, cur_subject + 1, num_of_continue + 1) + price[prev_school][cur_subject]); } else { for (int next_school = 0; next_school < n; next_school++) { if (info[next_school] == prev_school) continue; if (next_school == prev_school) { if (num_of_continue < e) ret = min(ret, find1(next_school, cur_subject + 1, num_of_continue + 1) + price[next_school][cur_subject]); } else ret = min(ret, find1(next_school, cur_subject + 1, 1) + price[next_school][cur_subject] + t); } } return ret; } int main() { scanf("%d%d%d%d%d", &n, &m, &s, &e, &t); memset(cache, -1, sizeof(cache)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { scanf("%d", &price[i][j]); } } for (int i = 0; i < n; i++) { int temp; scanf("%d", &temp); info[i] = temp - 1; } int min_price = 1234567890; for (int start = 0; start < n; start++) { min_price = min(min_price, find1(start, 1, 1) + price[start][0]); } printf("%d\n", min_price); }
댓글을 작성하려면
로그인
해야 합니다.
yomyom0824 5년 전
탑다운으로 풀었는데요.
어느 부분이 문제가 있는지 도저히 모르겠습니다 ㅠㅠ 도와주세요.