Skip to content

Added tasks 3536-3539 #1974

New issue

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

Merged
merged 8 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed style
  • Loading branch information
javadev committed May 4, 2025
commit 7dd3084c76558df1f4328fcef3774ff8384fea8e
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public int maxProduct(int n) {
while (n > 0) {
int a = n % 10;
if (a > m1) {
if (m1 > m2) m2 = m1;
if (m1 > m2) {
m2 = m1;
}
m1 = a;
} else {
if (a > m2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ public int minTravelTime(int l, int n, int k, int[] position, int[] time) {
for (int curr = 0; curr <= k && curr <= i; curr++) {
currTime += time[i - curr];
for (int used = 0; used <= k; used++) {
if (dp[i][curr][used] == Integer.MAX_VALUE) continue;
if (dp[i][curr][used] == Integer.MAX_VALUE) {
continue;
}
for (int next = 0; next <= k - used && next <= n - i - 2; next++) {
int nextI = i + next + 1;
dp[nextI][next][next + used] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public int magicalSum(int m, int k, int[] nums) {
pow[j][c] = pow[j][c - 1] * nums[j] % MOD;
}
}
long[][][] dp = new long[m + 1][k + 1][m + 1], next = new long[m + 1][k + 1][m + 1];
long[][][] dp = new long[m + 1][k + 1][m + 1];
long[][][] next = new long[m + 1][k + 1][m + 1];
dp[0][0][0] = 1L;
for (int i = 0; i < n; i++) {
for (int t = 0; t <= m; t++) {
Expand All @@ -29,10 +30,14 @@ public int magicalSum(int m, int k, int[] nums) {
for (int t = 0; t <= m; t++) {
for (int o = 0; o <= k; o++) {
for (int c = 0; c <= m; c++) {
if (dp[t][o][c] == 0) continue;
if (dp[t][o][c] == 0) {
continue;
}
for (int cc = 0; cc <= m - t; cc++) {
int total = c + cc;
if (o + (total & 1) > k) continue;
if (o + (total & 1) > k) {
continue;
}
next[t + cc][o + (total & 1)][total >>> 1] =
(next[t + cc][o + (total & 1)][total >>> 1]
+ dp[t][o][c]
Expand Down
close