git reimport
This commit is contained in:
37
archive/2018.10/2018.10.06 - unsorted/TaskA.java
Normal file
37
archive/2018.10/2018.10.06 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
char[] c = in.nextString().toCharArray();
|
||||
String s = in.nextString();
|
||||
boolean horizontal = false;
|
||||
if (s.contains("T")) {
|
||||
horizontal = true;
|
||||
}
|
||||
if (c[n - 1] == 'B' || c[n - 1] == 'T') {
|
||||
if (horizontal) {
|
||||
out.println(3);
|
||||
} else {
|
||||
out.println(2);
|
||||
}
|
||||
} else {
|
||||
if (horizontal) {
|
||||
out.println(2);
|
||||
} else {
|
||||
out.println(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
41
archive/2018.10/2018.10.06 - unsorted/TaskA.json
Normal file
41
archive/2018.10/2018.10.06 - unsorted/TaskA.json
Normal file
File diff suppressed because one or more lines are too long
47
archive/2018.10/2018.10.15 - SNCKQL19/CHEFPRMS.java
Normal file
47
archive/2018.10/2018.10.15 - SNCKQL19/CHEFPRMS.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
import misc.Stuff;
|
||||
|
||||
|
||||
public class CHEFPRMS extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
|
||||
List<Integer> primes = Stuff.generatePrimes(1000);
|
||||
Set<Integer> semiprimes = new HashSet<>();
|
||||
Set<Integer> sums = new HashSet<>();
|
||||
|
||||
{
|
||||
for (int i = 0; i < primes.size(); i++) {
|
||||
for (int j = i + 1; j < primes.size(); j++) {
|
||||
int sp = primes.get(i) * primes.get(j);
|
||||
if (sp < 1000) {
|
||||
semiprimes.add(sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i : semiprimes) {
|
||||
for (int j : semiprimes) {
|
||||
sums.add(i + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
out.println(sums.contains(n) ? "YES" : "NO");
|
||||
}
|
||||
}
|
34
archive/2018.10/2018.10.15 - SNCKQL19/CHEFPRMS.json
Normal file
34
archive/2018.10/2018.10.15 - SNCKQL19/CHEFPRMS.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "CHEFPRMS",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "3\n30\n45\n62",
|
||||
"output" : "YES\nYES\nNO",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.CHEFPRMS",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.15",
|
||||
"contestName" : "SNCKQL19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
25
archive/2018.10/2018.10.15 - SNCKQL19/HS08TEST.java
Normal file
25
archive/2018.10/2018.10.15 - SNCKQL19/HS08TEST.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class HS08TEST extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int x = in.nextInt();
|
||||
double y = in.nextDouble();
|
||||
|
||||
if (x + 0.5 > y || x % 5 != 0) {
|
||||
out.println(y);
|
||||
} else {
|
||||
out.println(y - x - 0.5);
|
||||
}
|
||||
}
|
||||
}
|
44
archive/2018.10/2018.10.15 - SNCKQL19/HS08TEST.json
Normal file
44
archive/2018.10/2018.10.15 - SNCKQL19/HS08TEST.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name" : "HS08TEST",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "30 120.00",
|
||||
"output" : "89.50",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "42 120.00",
|
||||
"output" : "120.00",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "300 120.00",
|
||||
"output" : "120.00",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.HS08TEST",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.15",
|
||||
"contestName" : "SNCKQL19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
42
archive/2018.10/2018.10.15 - SNCKQL19/TaskA.java
Normal file
42
archive/2018.10/2018.10.15 - SNCKQL19/TaskA.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
List<Integer> teams = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
teams.add(in.nextInt());
|
||||
}
|
||||
|
||||
teams.sort((o1, o2) -> -Integer.compare(o1, o2));
|
||||
|
||||
int res = 0;
|
||||
int cutoff = teams.get(k - 1);
|
||||
|
||||
for (Integer team : teams) {
|
||||
if (team >= cutoff) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
|
||||
out.println(res);
|
||||
}
|
||||
}
|
34
archive/2018.10/2018.10.15 - SNCKQL19/TaskA.json
Normal file
34
archive/2018.10/2018.10.15 - SNCKQL19/TaskA.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "TaskA",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "2\n5 1\n3 5 2 4 5\n6 4\n6 5 4 3 2 1",
|
||||
"output" : "2\n4",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskA",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.15",
|
||||
"contestName" : "SNCKQL19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
92
archive/2018.10/2018.10.29 - SNCK1B19/CHEFKO.java
Normal file
92
archive/2018.10/2018.10.29 - SNCK1B19/CHEFKO.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class CHEFKO extends SimpleSavingChelperSolution {
|
||||
|
||||
public static final Comparator<int[]> COMPARATOR = (o1, o2) -> {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int t = Integer.compare(o1[i], o2[i]);
|
||||
if (t != 0) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
int[][] a = new int[n][2];
|
||||
List<int[]> events = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i][0] = in.nextInt();
|
||||
a[i][1] = in.nextInt();
|
||||
|
||||
events.add(new int[]{a[i][0], -2, i});
|
||||
events.add(new int[]{a[i][1], +2, i});
|
||||
}
|
||||
|
||||
events.sort(COMPARATOR);
|
||||
|
||||
int maxLength = 0;
|
||||
|
||||
TreeSet<int[]> left = new TreeSet<>(COMPARATOR);
|
||||
TreeSet<int[]> right = new TreeSet<>(COMPARATOR);
|
||||
|
||||
for (int ei = 0; ei < events.size(); ) {
|
||||
int t = events.get(ei)[0];
|
||||
|
||||
while (ei < events.size() && events.get(ei)[0] == t && events.get(ei)[1] == -2) {
|
||||
int i = events.get(ei)[2];
|
||||
int[] key = {a[i][0], -2, i};
|
||||
|
||||
if (left.size() < k) {
|
||||
left.add(key);
|
||||
} else {
|
||||
right.add(key);
|
||||
}
|
||||
|
||||
ei++;
|
||||
}
|
||||
|
||||
if (events.get(ei)[0] == t && events.get(ei)[1] == +2 && left.size() == k) {
|
||||
maxLength = Math.max(maxLength, t - left.last()[0]);
|
||||
}
|
||||
|
||||
while (ei < events.size() && events.get(ei)[0] == t && events.get(ei)[1] == +2) {
|
||||
int i = events.get(ei)[2];
|
||||
int[] key = {a[i][0], -2, i};
|
||||
|
||||
if (left.contains(key)) {
|
||||
left.remove(key);
|
||||
|
||||
if (!right.isEmpty()) {
|
||||
left.add(right.pollFirst());
|
||||
}
|
||||
} else {
|
||||
right.remove(key);
|
||||
}
|
||||
|
||||
ei++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
out.println(maxLength);
|
||||
}
|
||||
}
|
64
archive/2018.10/2018.10.29 - SNCK1B19/CHEFKO.json
Normal file
64
archive/2018.10/2018.10.29 - SNCK1B19/CHEFKO.json
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name" : "CHEFKO",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "1\n3 2\n1 6\n2 4\n3 6",
|
||||
"output" : "3",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n5 2\n1 6\n1 3\n2 4\n3 5\n4 6",
|
||||
"output" : "2",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n4 2\n1 10\n3 8\n2 6\n5 9",
|
||||
"output" : "5",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n4 3\n1 10\n3 8\n2 6\n5 9",
|
||||
"output" : "3",
|
||||
"index" : 3,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n4 2\n1 3\n2 4\n3 5\n4 6",
|
||||
"output" : "1",
|
||||
"index" : 4,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n4 4\n1 3\n1 3\n1 3\n2 3",
|
||||
"output" : "1",
|
||||
"index" : 5,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n5 1\n1 3\n1 4\n5 9\n10 20\n1 100",
|
||||
"output" : "99",
|
||||
"index" : 6,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.CHEFKO",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.29",
|
||||
"contestName" : "SNCK1B19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
33
archive/2018.10/2018.10.29 - SNCK1B19/CHFAR.java
Normal file
33
archive/2018.10/2018.10.29 - SNCK1B19/CHFAR.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class CHFAR extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
int large = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
int x = in.nextInt();
|
||||
if (x > 1) {
|
||||
large++;
|
||||
}
|
||||
}
|
||||
|
||||
if (large > k) {
|
||||
out.println("NO");
|
||||
} else {
|
||||
out.println("YES");
|
||||
}
|
||||
}
|
||||
}
|
34
archive/2018.10/2018.10.29 - SNCK1B19/CHFAR.json
Normal file
34
archive/2018.10/2018.10.29 - SNCK1B19/CHFAR.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "CHFAR",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "1\n2 2\n1 2",
|
||||
"output" : "YES",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.CHFAR",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.29",
|
||||
"contestName" : "SNCK1B19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
54
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.java
Normal file
54
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class MAXPRODU extends SimpleSavingChelperSolution {
|
||||
|
||||
public static final long MOD = 1000000007;
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long n = in.nextLong();
|
||||
long k = in.nextLong();
|
||||
|
||||
if (n < (1 + k) * k / 2) {
|
||||
out.println(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
long[] a = new long[(int) k];
|
||||
|
||||
long next = 1;
|
||||
long left = n;
|
||||
int i = 0;
|
||||
|
||||
while (i < k) {
|
||||
long sum = (next + next + k - i - 1) * (k - i) / 2;
|
||||
if (sum > left) {
|
||||
left -= a[i];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
a[i] = next;
|
||||
next++;
|
||||
}
|
||||
|
||||
long res = 1;
|
||||
for (long j : a) {
|
||||
res *= (j * j - j) % MOD;
|
||||
res %= MOD;
|
||||
}
|
||||
|
||||
out.println(res);
|
||||
}
|
||||
}
|
43
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.json
Normal file
43
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name" : "MAXPRODU",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "2\n5 2\n6 2\n",
|
||||
"output" : "12\n24",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n50 3",
|
||||
"output" : "17478720",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "1\n1000000000 1000",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.MAXPRODU",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.29",
|
||||
"contestName" : "SNCK1B19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
52
archive/2018.10/2018.10.29 - SNCK1B19/QUEUE2.java
Normal file
52
archive/2018.10/2018.10.29 - SNCK1B19/QUEUE2.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class QUEUE2 extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long n = in.nextLong();
|
||||
long m = in.nextLong() + 1;
|
||||
long k = in.nextLong();
|
||||
long l = in.nextLong();
|
||||
|
||||
long lastFree = 0;
|
||||
|
||||
List<Long> a = new ArrayList<>();
|
||||
for (long i = 0; i < n; i++) {
|
||||
a.add(in.nextLong());
|
||||
}
|
||||
Collections.sort(a);
|
||||
a.add(k);
|
||||
|
||||
long minWaitTime = m * l;
|
||||
|
||||
for (long i : a) {
|
||||
long newlyFree = (i - lastFree) / l;
|
||||
lastFree += newlyFree * l;
|
||||
m = Math.max(0, m - newlyFree);
|
||||
|
||||
if (m == 0) {
|
||||
lastFree = i;
|
||||
}
|
||||
|
||||
minWaitTime = Math.min(minWaitTime, Math.max(lastFree + m * l - i, 0));
|
||||
|
||||
m++;
|
||||
}
|
||||
|
||||
out.println(minWaitTime);
|
||||
}
|
||||
}
|
34
archive/2018.10/2018.10.29 - SNCK1B19/QUEUE2.json
Normal file
34
archive/2018.10/2018.10.29 - SNCK1B19/QUEUE2.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "QUEUE2",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "4\n6 5 19 3\n4 8 16 12 14 18\n1 10 20 3\n3\n5 2 6 10\n1 2 5 3 4\n1 1 9 5\n8",
|
||||
"output" : "12\n16\n29\n2",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.QUEUE2",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.29",
|
||||
"contestName" : "SNCK1B19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
33
archive/2018.10/2018.10.29 - SNCK1B19/SNCKYEAR.java
Normal file
33
archive/2018.10/2018.10.29 - SNCK1B19/SNCKYEAR.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class SNCKYEAR extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
Set<Integer> set = new HashSet<>();
|
||||
|
||||
set.add(2010);
|
||||
set.add(2015);
|
||||
set.add(2016);
|
||||
set.add(2017);
|
||||
set.add(2019);
|
||||
|
||||
if (set.contains(in.nextInt())) {
|
||||
out.println("HOSTED");
|
||||
} else {
|
||||
out.println("NOT HOSTED");
|
||||
}
|
||||
}
|
||||
}
|
34
archive/2018.10/2018.10.29 - SNCK1B19/SNCKYEAR.json
Normal file
34
archive/2018.10/2018.10.29 - SNCK1B19/SNCKYEAR.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "SNCKYEAR",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "2\n2019\n2018",
|
||||
"output" : "HOSTED\nNOT HOSTED",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.SNCKYEAR",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2018.10.29",
|
||||
"contestName" : "SNCK1B19",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
Reference in New Issue
Block a user