git reimport

This commit is contained in:
2019-03-15 13:47:54 +04:00
commit 3b461f73de
489 changed files with 1631603 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class Task extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
int s = in.nextInt();
int n = in.nextInt();
int[] a = in.nextIntArray(n);
boolean[][] dp = new boolean[2][s + 1];
dp[0][0]= true;
for (int i = 1; i < n + 1; i++) {
for (int j = 0; j < s + 1; j++) {
dp[i % 2][j] = dp[(i - 1) % 2][j];
if (j - a[i - 1] >= 0 && dp[(i - 1) % 2][j - a[i - 1]]) {
dp[i % 2][j] = true;
}
}
}
for (int i = s; i >= 0; i--) {
if (dp[n % 2][i]) {
out.println(i);
return;
}
}
out.println(0);
}
}

View File

@@ -0,0 +1,38 @@
{
"name" : "Task",
"testType" : "SINGLE",
"input" : {
"type" : "STANDARD",
"fileName" : "knapsack.in"
},
"output" : {
"type" : "STANDARD",
"fileName" : "knapsack.out"
},
"tests" : [ {
"input" : "10 3\n1 4 8",
"output" : "9",
"index" : 0,
"active" : true
}, {
"input" : "20 4\n5 7 12 18",
"output" : "19",
"index" : 1,
"active" : true
} ],
"location" : "src/chelper",
"vmArgs" : "-Xmx256m -Xss64m",
"mainClass" : "Main",
"taskClass" : "chelper.Task",
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
"checkerParameters" : "",
"testClasses" : [ ],
"date" : "2018.09.18",
"contestName" : "",
"truncate" : true,
"inputClass" : "io.InputReader",
"outputClass" : "io.OutputWriter",
"includeLocale" : false,
"failOnOverflow" : false,
"interactive" : false
}

View File

@@ -0,0 +1,50 @@
package chelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class Task2 extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
List<Integer> piramidSizes = new ArrayList<>();
int max = 300_001;
int[] dp = new int[max];
{
piramidSizes.add(0);
for (int i = 1; true; i++) {
piramidSizes.add(piramidSizes.get(i - 1) + (1 + i) * i / 2);
if (piramidSizes.get(i) >= max) {
break;
}
}
Arrays.fill(dp, max);
dp[0] = 0;
for (int i = 1; i < max; i++) {
for (int j : piramidSizes) {
if (j > i) {
break;
}
dp[i] = Math.min(dp[i], dp[i - j] + 1);
}
}
}
@Override
public void solve(int testNumber) {
int x = in.nextInt();
out.println(dp[x]);
}
}

View File

@@ -0,0 +1,33 @@
{
"name" : "Task2",
"testType" : "MULTI_NUMBER",
"input" : {
"type" : "STANDARD",
"fileName" : "input.txt"
},
"output" : {
"type" : "STANDARD",
"fileName" : "output.txt"
},
"tests" : [ {
"input" : "5\n1\n5\n9\n15\n91",
"output" : "1\n2\n3\n3\n2",
"index" : 0,
"active" : true
} ],
"location" : "src/chelper",
"vmArgs" : "-Xmx256m -Xss64m",
"mainClass" : "Main",
"taskClass" : "chelper.Task2",
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
"checkerParameters" : "",
"testClasses" : [ ],
"date" : "2018.09.18",
"contestName" : "",
"truncate" : true,
"inputClass" : "io.InputReader",
"outputClass" : "io.OutputWriter",
"includeLocale" : false,
"failOnOverflow" : false,
"interactive" : false
}