Guest User

Untitled

a guest
Oct 17th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. //퇴사
  2. #include <cstdio>
  3. #include <vector>
  4. using namespace std;
  5. struct info {
  6. int t;
  7. int p;
  8. info(int lng, int pay) {
  9. t = lng;
  10. p = pay;
  11. }
  12. };
  13. int N, a, b, ans = 0;
  14. vector<info> date;
  15. void dfs(int cnt, int idx) {
  16. if (idx > N) return;
  17. if (ans < cnt)
  18. ans = cnt;
  19. for (int i = idx + 1; i <= N; i++) {
  20. dfs(cnt + date[i].p, i + date[i].t - 1);
  21. }
  22. }
  23. int main() {
  24. scanf("%d", &N);
  25. date.push_back(info(0, 0));
  26. for (int i = 0; i < N; i++) {
  27. scanf("%d%d", &a, &b);
  28. info tmp(a, b);
  29. date.push_back(tmp);
  30. }
  31. dfs(0, 0);
  32. printf("%d\n", ans);
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment