Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb39b17

Browse files
authored
Create: 2140-solving-questions-with-brainpower.c
1 parent38d4fc8 commitbb39b17

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
long longmostPoints(int**questions,intquestionsSize,int*questionsColSize) {
2+
intn=questionsSize;
3+
long long*dp= (long long*)malloc((n+1)*sizeof(long long));
4+
5+
for (inti=0;i <=n;i++) {
6+
dp[i]=0;
7+
}
8+
9+
for (inti=n-1;i >=0;i--) {
10+
intpoints=questions[i][0];
11+
intjump=questions[i][1];
12+
dp[i]= (points+dp[(jump+i+1)<n ? (jump+i+1) :n])>dp[i+1] ? (points+dp[(jump+i+1)<n ? (jump+i+1) :n]) :dp[i+1];
13+
}
14+
15+
long longresult=dp[0];
16+
free(dp);
17+
returnresult;
18+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp