static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var sx = scanner.Integer(); var sy = scanner.Integer(); var tx = scanner.Integer(); var ty = scanner.Integer(); var ret = new StringBuilder(); ret.Append(new string('R', tx - sx)); ret.Append(new string('U', ty - sy)); ret.Append(new string('L', tx - sx)); ret.Append(new string('D', ty - sy)); ret.Append("D"); ret.Append(new string('R', tx - sx + 1)); ret.Append(new string('U', ty - sy + 1)); ret.Append("L"); ret.Append("U"); ret.Append(new string('L', tx - sx + 1)); ret.Append(new string('D', ty - sy + 1)); ret.Append("R"); IO.Printer.Out.WriteLine(ret.ToString()); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var fs = new List <int[]>(); var ps = new List <int[]>(); for (int i = 0; i < n; i++) { fs.Add(scanner.ScanLine().Split().Select(v => int.Parse(v)).ToArray()); } for (int i = 0; i < n; i++) { ps.Add(scanner.ScanLine().Split().Select(v => int.Parse(v)).ToArray()); } var ret = long.MinValue; for (int flg = 1; flg < 1 << 10; flg++) { ret = Math.Max(ret, GetAns(n, fs, ps, flg)); } IO.Printer.Out.WriteLine(ret); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var a = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList(); var colors = new int[9]; foreach (var v in a) { colors[(v / 400 > 8) ? 8 : v / 400]++; } var num = 0; for (int i = 0; i < 8; i++) { if (colors[i] > 0) { num++; } } var minNum = num > 0 ? num : 1; var maxNum = num + colors[8]; IO.Printer.Out.WriteLine(minNum + " " + maxNum); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var a = scanner.ScanLine().Split().Select(v => long.Parse(v)).ToList(); var ret = 0L; var cnt = 0; a.Sort(); var idx = a.Count() - 2; while (cnt < n) { ret += a[idx]; idx -= 2; cnt++; } IO.Printer.Out.WriteLine(ret); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var a = new List <int>(); for (int i = 0; i < n; i++) { a.Add(scanner.Integer()); } IO.Printer.Out.WriteLine(GetAns(n, a)); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var m = scanner.Integer(); var cakes = new List <Tuple <long, long, long> >(); for (int i = 0; i < n; i++) { cakes.Add(new Tuple <long, long, long>(scanner.Long(), scanner.Long(), scanner.Long())); } IO.Printer.Out.WriteLine(GetAns(n, m, cakes)); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var m = scanner.Integer(); var p = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList(); var pairs = new List <Tuple <int, int> >(); for (int i = 0; i < m; i++) { pairs.Add(new Tuple <int, int>(scanner.Integer(), scanner.Integer())); } IO.Printer.Out.WriteLine(GetAns(n, m, p, pairs)); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var m = scanner.Integer(); var graph = new BICC(n); for (int i = 0; i < m; i++) { graph.AddEdge(scanner.Integer() - 1, scanner.Integer() - 1); } graph.GetBicc(); IO.Printer.Out.WriteLine(graph._bridges.Count()); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var ss = new List <string>(); for (int i = 0; i < n; i++) { ss.Add(scanner.ScanLine()); } var strsDict = new Dictionary <char, int>(); foreach (var s in ss) { if (!"MARCH".Contains(s[0])) { continue; } if (!strsDict.ContainsKey(s[0])) { strsDict.Add(s[0], 0); } strsDict[s[0]]++; } var ret = 0L; var combi = new List <char[]>(); var array = "MARCH".ToCharArray(); GetPermutation(ref combi, array, 0, array.Length - 1); var allCombi = new HashSet <string>(); foreach (var c in combi) { allCombi.Add(new string(c.Take(3).OrderBy(d => d).ToArray())); } foreach (var ptn in allCombi.ToList()) { if (!strsDict.ContainsKey(ptn[0]) || !strsDict.ContainsKey(ptn[1]) || !strsDict.ContainsKey(ptn[2])) { continue; } ret += ((long)strsDict[ptn[0]] * (long)strsDict[ptn[1]] * (long)strsDict[ptn[2]]); } IO.Printer.Out.WriteLine(ret); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var c = scanner.Integer(); var ds = new List <List <int> >(); for (int i = 0; i < c; i++) { ds.Add(scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList()); } var grid = new List <List <int> >(); for (int i = 0; i < n; i++) { grid.Add(scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList()); } IO.Printer.Out.WriteLine(GetAns(n, c, ds, grid)); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var a = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList(); var ret = int.MinValue; for (int i = 0; i < a.Count(); i++) { var aScore = int.MinValue; var aIdx = -1; for (int j = 0; j < a.Count(); j++) { if (i == j) { continue; } var newAScore = 0; for (int k = Math.Min(i, j); k <= Math.Max(i, j); k++) { if ((k - Math.Min(i, j)) % 2 == 1) { newAScore += a[k]; } } if (newAScore > aScore) { aScore = newAScore; aIdx = j; } } var tScore = 0; for (int j = Math.Min(i, aIdx); j <= Math.Max(i, aIdx); j++) { if ((j - Math.Min(i, aIdx)) % 2 == 0) { tScore += a[j]; } } ret = Math.Max(ret, tScore); } IO.Printer.Out.WriteLine(ret); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var m = scanner.Integer(); var x = scanner.Integer(); var y = scanner.Integer(); var a = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList(); var b = scanner.ScanLine().Split().Select(v => int.Parse(v)).ToList(); var ret = 0; var cur = true; var curPos = 0; while (true) { var tgt = cur ? a : b; var lb = LowerBound(tgt, curPos); if (lb >= tgt.Count()) { break; } curPos = tgt[lb] + (cur ? x : y); if (tgt == b) { ret++; } cur = !cur; } IO.Printer.Out.WriteLine(ret); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var s = scanner.ScanLine(); IO.Printer.Out.WriteLine(GetAns(s)); IO.Printer.Out.Flush(); }
static void Main(string[] args) { #if DEBUG var scanner = new IO.StreamScanner(File.Open("input.txt", FileMode.Open)); #else var scanner = new IO.StreamScanner(Console.OpenStandardInput()); #endif var n = scanner.Integer(); var ans = GetAns(n); foreach (var a in ans) { IO.Printer.Out.Write(a + " "); } IO.Printer.Out.Flush(); }
static void Main(string[] args) { var t = _scanner.Integer(); }