Skip to content

Instantly share code, notes, and snippets.

@alculquicondor
Created November 26, 2016 03:16
Show Gist options
  • Select an option

  • Save alculquicondor/703aff155d435e65d46b25bce499f090 to your computer and use it in GitHub Desktop.

Select an option

Save alculquicondor/703aff155d435e65d46b25bce499f090 to your computer and use it in GitHub Desktop.
Solución del problema del CEP2016: "Chusky y el juego de las Murallas"
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Aldo Culquicondor
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
CEP2016R solver = new CEP2016R();
solver.solve(0, in, out);
out.close();
}
static class CEP2016R {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n1 = in.nextInt(), m1 = in.nextInt(), n2 = in.nextInt(), m2 = in.nextInt();
int[] q = new int[2];
for (int i = 0; i < n1; ++i)
q[0] += in.nextInt();
for (int i = 0; i < n2; ++i)
q[1] += in.nextInt();
for (int i = 0; i < m1 + m2; ++i) {
int w = in.nextInt() - 1, x = in.nextInt(), y = in.nextInt(), z = in.nextInt();
q[z > 0 ? w : 1 - w] += z * (y - x + 1);
}
if (q[0] > q[1])
out.println(1);
else if (q[1] > q[0])
out.println(2);
else
out.println(0);
}
}
static class InputReader {
private BufferedReader reader;
private StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 65536);
tokenizer = null;
}
public String next() {
String line;
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
line = reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
if (line == null)
throw new UnknownError();
tokenizer = new StringTokenizer(line);
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment