From fdb58f3278cfb30b77355bfb1c0c2920e9db4145 Mon Sep 17 00:00:00 2001 From: cyp0633 Date: Sat, 31 Jul 2021 22:01:49 +0800 Subject: [PATCH] CSP 5-8 jump Passed example; all WA on Codeforces --- CSP-Training/5/8-jump.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CSP-Training/5/8-jump.cpp diff --git a/CSP-Training/5/8-jump.cpp b/CSP-Training/5/8-jump.cpp new file mode 100644 index 0000000..cf3336a --- /dev/null +++ b/CSP-Training/5/8-jump.cpp @@ -0,0 +1,28 @@ +//CF1472C Long Jumps +#include +#include +#include +#include +using namespace std; + +int main() +{ + int t, n; + map dp; + long long int a, maxScore; + scanf("%d", &t); + while (t--) + { + dp.clear(); + maxScore = -1; + scanf("%d", &n); + for (int i = 0; i < n; i++) + { + scanf("%lld", &a); + dp[i + a] = dp[i + a] > dp[i] + a ? dp[i + a] : dp[i] + a; + maxScore = maxScore > dp[i + a] ? maxScore : dp[i + a]; + } + printf("%lld\n", maxScore); + } + return 0; +} \ No newline at end of file