public void Solve(ConsoleInput cin) { var S = cin.Read.Reverse(); var words = new string[] { "maerd", "remaerd", "esare", "resare" }; var flag = true; for (int i = 0; i < S.Length;) { var flag2 = false; foreach (var x in words) { if (S.Length - i < x.Length) { continue; } if (S.Substring(i, x.Length) == x) { flag2 = true; i += x.Length; break; } } if (!flag2) { flag = false; break; } } if (flag) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } }
public void Solve(ConsoleInput cin) { var n = int.Parse(cin.ReadLine); var r = cin.ReadIntArray(n); if (n == 1 && r[0] == 1) { Console.WriteLine(0); return; } int cnt = 0; int num = 1; bool flg = false; for (int i = 0; i < n; i++) { if (r[i] == num) { num++; flg = true; } else { cnt++; } } if (flg) { Console.WriteLine(cnt); } else { Console.WriteLine(-1); } }
public void Solve(ConsoleInput cin) { // ここに処理を書く long a = cin.ReadLong; long b = cin.ReadLong; long k = cin.ReadLong; long ar; long br; if (a < k) { ar = 0; long tmp = k - a; br = Math.Max(0, b - tmp); } else { ar = a - k; br = b; } Console.WriteLine(ar + " " + br); }
public void Solve(ConsoleInput cin) { Console.WriteLine(cin.ReadLine.Count(x => x == '1')); }