private static void Main() { int arrayLength; while ((arrayLength = FastIO.ReadNonNegativeInt()) != 0) { int queryCount = FastIO.ReadNonNegativeInt(); int[] sourceArray = new int[arrayLength]; for (int i = 0; i < arrayLength; ++i) { sourceArray[i] = FastIO.ReadInt(); } var solver = new FREQUENT(sourceArray); for (int q = 0; q < queryCount; ++q) { FastIO.WriteInt(solver.Query( queryStartIndex: FastIO.ReadNonNegativeInt() - 1, queryEndIndex: FastIO.ReadNonNegativeInt() - 1)); FastIO.WriteLine(); } } FastIO.Flush(); }
private static void Main() { int remainingTestCases = FastIO.ReadNonNegativeInt(); while (remainingTestCases-- > 0) { int knownLength = FastIO.ReadNonNegativeInt(); int unknownLength = FastIO.ReadNonNegativeInt(); int?[] sequence = new int?[knownLength + unknownLength]; for (int i = 0; i < knownLength; ++i) { sequence[i] = FastIO.ReadInt(); } CMPLS.Solve(sequence, knownLength, unknownLength); for (int i = knownLength; i < sequence.Length; ++i) { FastIO.WriteNonNegativeInt(sequence[i].Value); FastIO.WriteSpace(); } FastIO.WriteLine(); } FastIO.Flush(); }
private static void Main() { var output = new StringBuilder(); int testCount = FastIO.ReadNonNegativeInt(); for (int t = 1; t <= testCount; ++t) { int scoreCount = FastIO.ReadNonNegativeInt(); int queryCount = FastIO.ReadNonNegativeInt(); int[] scores = new int[scoreCount]; for (int s = 0; s < scoreCount; ++s) { scores[s] = FastIO.ReadInt(); } var solver = new RPLN(scores); output.AppendLine($"Scenario #{t}:"); for (int q = 0; q < queryCount; ++q) { output.Append(solver.Solve( queryStartIndex: FastIO.ReadNonNegativeInt() - 1, queryEndIndex: FastIO.ReadNonNegativeInt() - 1)); output.AppendLine(); } } Console.Write(output); }
private static void Main() { int remainingTestCases = FastIO.ReadNonNegativeInt(); while (remainingTestCases-- > 0) { int matrixSize = FastIO.ReadNonNegativeInt(); var solver = new MATSUM(matrixSize); char command; while ((command = FastIO.ReadCommand()) != 'E') { if (command == 'S') { solver.Set( rowIndex: FastIO.ReadNonNegativeInt(), columnIndex: FastIO.ReadNonNegativeInt(), value: FastIO.ReadInt()); } else { FastIO.WriteInt(solver.Query( nearRowIndex: FastIO.ReadNonNegativeInt(), nearColumnIndex: FastIO.ReadNonNegativeInt(), farRowIndex: FastIO.ReadNonNegativeInt(), farColumnIndex: FastIO.ReadNonNegativeInt())); FastIO.WriteLine(); } } FastIO.WriteLine(); } FastIO.Flush(); }
private static void Main() { int n = FastIO.ReadNonNegativeInt(); for (int i = 0; i < n; ++i) { FastIO.WriteInt(FastIO.ReadInt() * FastIO.ReadInt()); FastIO.WriteLine(); } FastIO.Flush(); }
private static void Main() { int remainingTestCases = FastIO.ReadNonNegativeInt(); while (remainingTestCases-- > 0) { FastIO.WriteInt( TEMPLATE3.Solve(FastIO.ReadInt(), FastIO.ReadInt())); FastIO.WriteLine(); } FastIO.Flush(); }
private static void Main() { int operationCount = FastIO.ReadNonNegativeInt(); var operations = new Operation[operationCount]; var possibleValues = new HashSet <int>(); for (int o = 0; o < operationCount; ++o) { operations[o] = new Operation( operationType: FastIO.ReadOperationType(), operationParameter: FastIO.ReadInt()); if (operations[o].OperationType == 'I') { possibleValues.Add(operations[o].OperationParameter); } } var solver = new ORDERSET(possibleValues); var output = new StringBuilder(); for (int o = 0; o < operationCount; ++o) { switch (operations[o].OperationType) { case 'I': solver.Insert(value: operations[o].OperationParameter); break; case 'D': solver.Delete(value: operations[o].OperationParameter); break; case 'K': output.AppendLine(solver .GetKthSmallest(k: operations[o].OperationParameter) ?.ToString() ?? "invalid"); break; case 'C': output.AppendLine(solver .CountValuesSmallerThan(value: operations[o].OperationParameter) .ToString()); break; default: throw new InvalidOperationException(); } } Console.Write(output); }
private static void Main() { int sourceArrayLength = FastIO.ReadNonNegativeInt(); int queryCount = FastIO.ReadNonNegativeInt(); int[] sourceArray = new int[sourceArrayLength]; for (int i = 0; i < sourceArrayLength; ++i) { sourceArray[i] = FastIO.ReadInt(); } var solver = new MKTHNUM(sourceArray); for (int q = 0; q < queryCount; ++q) { FastIO.WriteInt(solver.Query( queryStartIndex: FastIO.ReadNonNegativeInt() - 1, queryEndIndex: FastIO.ReadNonNegativeInt() - 1, k: FastIO.ReadNonNegativeInt())); FastIO.WriteLine(); } FastIO.Flush(); }