We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go(day, sum)
go(day + t[day], sum + p[day])
go(day + 1, sum)
package main.java.com.poogle.BOJ.Q14501; import java.util.Scanner; public class Main { static int[] t; static int[] p; static int n; static int ans = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); t = new int[n + 1]; p = new int[n + 1]; for (int i = 1; i <= n; i++) { t[i] = sc.nextInt(); p[i] = sc.nextInt(); } go(1, 0); System.out.println(ans); } private static void go(int day, int sum) { if (day == n + 1) { if (ans < sum) ans = sum; return; } if (day > n + 1) { return; } go(day + t[day], sum + p[day]); go(day + 1, sum); } }
go()
private static void go(int day, int sum) { if (day == n + 1) { if (ans < sum) ans = sum; return; } if (day > n + 1) { return; } int t1 = go(day + 1); int t2 = p[day] + go(day + t[day]); d[day] = Math.max(t1, t2); return d[day]; // go(day + t[day], sum + p[day]); // go(day + 1, sum); }
The text was updated successfully, but these errors were encountered:
d747425
BOJ: 14501 풀이
2e5a2c9
- DP 풀이 추가 Issue #73
suhyunsim
No branches or pull requests
문제
핵심 아이디어
브루트포스로 풀이
go(day, sum)
go(day + t[day], sum + p[day])
go(day + 1, sum)
DP로 풀이
어려운 점, 실수
풀이
브루트포스
DP
go()
에서 한 부분만 수정The text was updated successfully, but these errors were encountered: