[Init] Solved solutions

This commit is contained in:
tiennm99 committed 2023-03-02 20:58:03 +07:00
1 parent 51f667ac81
commit 20542601dd
131 files changed
+4148

No files matched your search

+99
View File
@@ -0,0 +1,99 @@
using System;
namespace problem_1000A
{
class problem_1000A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = new int[9];
for (int i = 0; i<n; i++)
{
string s = Console.ReadLine();
if (s == "M")
{
a[0]++;
}
else if (s == "S")
{
a[1]++;
}
else if (s == "XS")
{
a[2]++;
}
else if (s == "XXS")
{
a[3]++;
}
else if (s == "XXXS")
{
a[4]++;
}
else if (s == "L")
{
a[5]++;
}
else if (s == "XL")
{
a[6]++;
}
else if (s == "XXL")
{
a[7]++;
}
else if (s == "XXXL")
{
a[8]++;
}
}
int c = 0;
for (int i = 0; i < n; i++)
{
string s = Console.ReadLine();
if (s == "M" && a[0] > 0)
{
a[0]--;
}
else if (s == "S" && a[1] > 0)
{
a[1]--;
}
else if (s == "XS" && a[2] > 0)
{
a[2]--;
}
else if (s == "XXS" && a[3] > 0)
{
a[3]--;
}
else if (s == "XXXS" && a[4] > 0)
{
a[4]--;
}
else if (s == "L" && a[5] > 0)
{
a[5]--;
}
else if (s == "XL" && a[6] > 0)
{
a[6]--;
}
else if (s == "XXL" && a[7] > 0)
{
a[7]--;
}
else if (s == "XXXL" && a[8] > 0)
{
a[8]--;
}
else
{
c++;
}
}
Console.Write(c);
}
}
}
+30
View File
@@ -0,0 +1,30 @@
using System;
namespace problem_1004A
{
public class problem_1004A
{
public static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int n = ip[0];
int d = ip[1];
ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int id = 1;
int count = 2;
while (id < n)
{
if (ip[id] - ip[id - 1] > 2*d)
{
count += 2;
}
else if (ip[id] - ip[id - 1] == 2*d)
{
count++;
}
id++;
}
Console.Write("{0}", count);
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace problem_1004B
{
class problem_1004B
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine().Split(' ')[0]);
for (int i = 0; i < n; i++)
{
if (i % 2 == 0)
{
Console.Write("1");
}
else
{
Console.Write("0");
}
}
}
}
}
+28
View File
@@ -0,0 +1,28 @@
using System;
using System.Collections;
namespace problem_1005A
{
class problem_1005A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
ArrayList b = new ArrayList();
for (int i = 0; i < n - 1; i++)
{
if (a[i + 1] == 1)
{
b.Add(a[i]);
}
}
b.Add(a[n - 1]);
Console.WriteLine(b.Count);
foreach (var t in b)
{
Console.Write("{0} ", t);
}
}
}
}
+24
View File
@@ -0,0 +1,24 @@
using System;
namespace problem_1006A
{
class problem_1006A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 0; i < n; i++)
{
if (a[i] % 2 == 0)
{
a[i]--;
}
}
foreach (int t in a)
{
Console.Write("{0} ", t);
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
using System;
using System.Linq;
namespace problem_1006B
{
class problem_1006B
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if (ip[1] == 1)
{
Console.WriteLine("{0}", a.Max());
Console.Write("{0}", ip[0]);
}
else
{
int[] b = new int[ip[1]];
int s = 0;
for (int i = 0; i < ip[1]; i++)
{
int m = a.Max();
s += m;
b[i] = Array.IndexOf(a, m);
a[b[i]] = 0;
}
Array.Sort(b);
Console.WriteLine(s);
Console.Write("{0} ", b[0] + 1);
for (int i = 1; i < ip[1] - 1; i++)
{
Console.Write("{0} ", b[i] - b[i - 1]);
}
Console.Write("{0}", ip[0] - b[ip[1] - 2] - 1);
}
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using System;
using System.Linq;
namespace problem_1008B
{
public class problem_1008B
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int c = int.MaxValue;
bool b = true;
for (int i = 0; i < n; i++)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if (c >= a.Max())
{
c = a.Max();
}
else if ( c >= a.Min())
{
c = a.Min();
}
else
{
b = false;
break;
}
}
if (b)
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
}
}
+41
View File
@@ -0,0 +1,41 @@
using System;
namespace problem_112A
{
public class problem_112A
{
public static int F(char[] c1, char[] c2)
{
int l = Math.Min(c1.Length, c2.Length);
for (int i = 0; i < l; i++)
{
if (c1[i] < c2[i])
{
return -1;
}
else if (c1[i] > c2[i])
{
return 1;
}
}
if (c1.Length > c2.Length)
{
return 1;
}
else if (c1.Length < c2.Length)
{
return -1;
}
else
{
return 0;
}
}
public static void Main(string[] args)
{
char[] c1 = Console.ReadLine().ToLower().ToCharArray();
char[] c2 = Console.ReadLine().ToLower().ToCharArray();
Console.Write("{0}", F(c1, c2));
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace _116A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int max = 0, cur = 0;
for (int i = 0; i < n; i++)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
cur = cur - a[0] + a[1];
if (cur > max)
{
max = cur;
}
}
Console.WriteLine(max);
}
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
namespace problem_118A
{
class problem_118A
{
static void Main(string[] args)
{
char[] r = {'a', 'o', 'y', 'e', 'u', 'i'};
string s = Console.ReadLine().ToLower();
foreach (char c in r)
{
s = s.Replace(char.ToString(c), "");
}
foreach (char c in s)
{
Console.Write(".{0}", c);
}
}
}
}
+46
View File
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _119A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Console.WriteLine(P(a[0], a[1], a[2]) ? 1 : 0);
}
static bool P(int a, int b, int c)
{
while (true)
{
int gcd = GCD(a, c);
c -= gcd;
if (c == 0)
{
return false;
}
gcd = GCD(b, c);
c -= gcd;
if (c == 0)
{
return true;
}
}
}
static int GCD(int a, int b)
{
int t;
while (b != 0)
{
t = a % b;
a = b;
b = t;
}
return a;
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace _122A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
if (n % 4 == 0 || n % 7 == 0 || n % 44 == 0 || n % 47 == 0 || n % 74 == 0 || n % 77 == 0 || n % 444 == 0 || n % 447 == 0 || n % 474 == 0 || n % 477 == 0 || n % 744 == 0 || n % 747 == 0 || n % 774 == 0 || n % 777 == 0)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
namespace problem_158A
{
public class problem_158A
{
static void Main(string[] args)
{
int[] line_1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] line_2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int c = 0;
for (int i = 0; i < line_1[0]; i++)
{
if (line_2[i] >= line_2[line_1[1] - 1] && line_2[i] > 0)
{
c++;
}
else
{
break;
}
}
Console.WriteLine(c);
}
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
namespace problem_158B
{
class problem_158B
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = new int[4];
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 0; i < n; i++)
{
a[ip[i] - 1]++;
}
int c = a[3];
c += a[2];
a[0] -= a[2];
if (a[0] < 0)
{
a[0] = 0;
}
c += a[1] / 2;
a[1] %= 2;
a[0] += 2 * a[1];
c += a[0] / 4;
if (a[0] % 4 != 0)
{
c++;
}
Console.Write(c);
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System;
namespace problem_1A
{
class problem_1A
{
static void Main(string[] args)
{
string s = Console.ReadLine();
string[] input = s.Split(' ');
long m = Convert.ToInt32(input[0]);
long n = Convert.ToInt32(input[1]);
long a = Convert.ToInt32(input[2]);
if (a != 0)
{
if (m % a == 0)
{
m /= a;
}
else
{
m = m / a + 1;
}
if (n % a == 0)
{
n /= a;
}
else
{
n = n / a + 1;
}
}
Console.WriteLine(m * n);
}
}
}
+58
View File
@@ -0,0 +1,58 @@
using System;
namespace problem_1B
{
class problem_1B
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
string s = Console.ReadLine();
int pos_R = s.IndexOf('R');
int pos_C = s.IndexOf('C');
if (pos_R == 0 && pos_C > 1 && char.IsDigit(s[1]))
{
int r = int.Parse(s.Substring(1, pos_C - 1));
int c = int.Parse(s.Substring(pos_C + 1, s.Length - 1 - pos_C));
string output = "";
while (c > 0)
{
if (c % 26 == 0)
{
output += "Z";
c = c / 26 - 1;
}
else
{
output += Convert.ToString(Convert.ToChar('A' + c % 26 - 1));
c /= 26;
}
}
for (int j = output.Length - 1; j >= 0; j--)
{
Console.Write(output[j]);
}
Console.WriteLine(r);
}
else
{
int j = 0;
int r = 0;
int c = 0;
while(char.IsDigit(s[j]) == false)
{
j++;
}
r = int.Parse(s.Substring(j, s.Length - j));
for (int k = 0; k < j; k++)
{
c = c * 26 + Convert.ToInt32(s[k]) + 1 - 'A';
}
Console.WriteLine("R{0}C{1}", r, c);
}
}
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace _214A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int i = 0, j = a[0], count = 0;
while (i <= a[0] && j >= 0)
{
if (i + j * j == a[1])
{
count++;
}
i++;
j = a[0] - i * i;
}
Console.WriteLine(count);
}
}
}
+48
View File
@@ -0,0 +1,48 @@
using System;
namespace _217A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] p = new int[n];
int[][] a = new int[n][];
int c = 0;
for (int i = 0; i < n; i++)
{
a[i] = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
p[i] = i;
}
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if (a[i][0] == a[j][0] || a[i][1] == a[j][1])
{
int ti = p[i];
while (ti != p[ti])
{
ti = p[ti];
}
int tj = p[j];
while (tj != p[tj])
{
tj = p[tj];
}
p[tj] = ti;
}
}
}
for (int i = 0; i < n; i++)
{
if (i == p[i])
{
c++;
}
}
Console.WriteLine(c - 1);
}
}
}
+49
View File
@@ -0,0 +1,49 @@
using System;
namespace problem_224B
{
class problem_224B
{
public static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int count = 0;
int[] c = new int[100000];
for (int i = 0; i < ip[0]; i++)
{
if (c[a[i] - 1]++ == 0)
{
count++;
}
}
if (count < ip[1])
{
Console.Write("-1 -1");
}
else
{
int i;
for (i = ip[0] - 1; count >= ip[1]; i--)
{
if (--c[a[i] - 1] == 0)
{
count--;
}
}
int r = ++i;
c[a[i] - 1]++;
count++;
for (i = 0; count == ip[1]; i++)
{
c[a[i] - 1]--;
if (c[a[i] - 1] == 0) count--;
}
int l = --i;
c[a[i] - 1]++;
count++;
Console.Write("{0} {1}", l + 1, r + 1);
}
}
}
}
+61
View File
@@ -0,0 +1,61 @@
using System;
namespace problem_230A
{
class problem_230A
{
static void Main(string[] args)
{
string[] ip;
ip = Console.ReadLine().Split(' ');
int s = int.Parse(ip[0]);
int n = int.Parse(ip[1]);
if (C(s, n))
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
static bool C(int s, int n)
{
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++)
{
string[] ip = Console.ReadLine().Split(' ');
a[i] = int.Parse(ip[0]);
b[i] = int.Parse(ip[1]);
}
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if (a[i] > a[j])
{
int t = a[i];
a[i] = a[j];
a[j] = t;
t = b[i];
b[i] = b[j];
b[j] = t;
}
}
}
for (int i = 0; i < n; i++)
{
if (s > a[i])
{
s += b[i];
}
else
{
return false;
}
}
return true;
}
}
}
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.Linq;
namespace problem_242B
{
class problem_242B
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
int[] b = new int[n];
for (int i = 0; i < n; i++)
{
string[] ip = Console.ReadLine().Split(' ');
a[i] = int.Parse(ip[0]);
b[i] = int.Parse(ip[1]);
}
int m1 = a.Min();
int m2 = b.Max();
int c = -1;
for (int i = 0; i < n; i++)
{
if (a[i] == m1 && b[i] == m2)
{
c = i + 1;
break;
}
}
Console.Write(c);
}
}
}
+23
View File
@@ -0,0 +1,23 @@
using System;
namespace problem_246A
{
class problem_246A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
if (n < 3)
{
Console.Write("{0}", -1);
}
else
{
for (int i = n; i > 0; i--)
{
Console.Write("{0} ", i);
}
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
namespace problem_266A
{
public class problem_266A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
char[] a = Console.ReadLine().ToCharArray();
int c = 0;
for (int i = 1; i < n; i++)
{
if (a[i] == a[i - 1])
{
c++;
}
}
Console.Write(c);
}
}
}
+86
View File
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _277A
{
class Program
{
static bool[,] board;
static int[] a;
static bool[] b;
static Queue<int> qi = new Queue<int>();
static void Main(string[] args)
{
a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
board = new bool[a[0], a[1]];
b = new bool[a[0]];
int count = 0;
int c = 0;
for (int i = 0; i < a[0]; i++)
{
int[] array = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if (array[0] == 0)
{
c++;
}
for (int j = 1; j <= array[0]; j++)
{
board[i, array[j] - 1] = true;
}
}
/*
for (int i = 0; i < a[0]; i++)
{
for (int j = 0; j < a[1]; j++)
{
Console.Write("{0} ", board[i, j] ? 1 : 0);
}
Console.WriteLine();
}
*/
if (c == a[0])
{
Console.WriteLine(c);
}
else
{
for (int i = 0; i < a[0]; i++)
{
if (b[i] == false)
{
count++;
DFS(i);
}
}
Console.WriteLine(count - 1);
}
}
static void DFS(int n)
{
b[n] = true;
qi.Enqueue(n);
while (qi.Count != 0)
{
int t = qi.First();
qi.Dequeue();
for (int j = 0; j < a[1]; j++)
{
if (board[t, j] == true)
{
for (int i = 0; i < a[0]; i++)
{
if (board[i, j] == true && b[i] == false)
{
b[i] = true;
qi.Enqueue(i);
}
}
}
}
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
namespace problem_279B
{
class problem_279B
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int c = 0, s = 0, x = 0;
for (int i = 0; i < ip[0]; i++)
{
s += a[i];
c++;
if (s > ip[1])
{
c--;
s -= a[x];
x++;
}
}
Console.Write(c);
}
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
namespace problem_281A
{
public class problem_281A
{
public static void Main(string[] args)
{
string ip = Console.ReadLine();
ip = char.ToUpper(ip[0]) + ip.Substring(1);
Console.Write(ip);
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
namespace problem_282A
{
public class problem_282A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int x = 0;
while (n-- > 0)
{
string s = Console.ReadLine();
if (s.Contains("++"))
{
x++;
}
else
{
x--;
}
}
Console.Write(x);
}
}
}
+64
View File
@@ -0,0 +1,64 @@
using System;
using System.Linq;
namespace _334B
{
class Program
{
static void Main(string[] args)
{
int[] x = new int[8];
int[] y = new int[8];
for (int i = 0; i < 8; i++)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
x[i] = ip[0];
y[i] = ip[1];
}
int[] xx = x.Distinct().ToArray();
int[] yy = y.Distinct().ToArray();
bool b = false;
if (xx.Length == 3 && yy.Length == 3)
{
Array.Sort(xx);
Array.Sort(yy);
b = true;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
if (i != 1 || j != 1)
{
bool c = false;
for (int k = 0; k < 8; k++)
{
if (x[k] == xx[i] && y[k] == yy[j])
{
c = true;
break;
}
}
b &= c;
}
if (b == false)
{
break;
}
}
if (b == false)
{
break;
}
}
}
if (b)
{
Console.WriteLine("respectable");
}
else
{
Console.WriteLine("ugly");
}
}
}
}
+29
View File
@@ -0,0 +1,29 @@
using System;
namespace problem_339A
{
public class problem_339A
{
public static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split('+'), int.Parse);
for (int i = 0; i < a.Length - 1; i++)
{
for (int j = i + 1; j < a.Length; j++)
{
if (a[j] < a[i])
{
int t = a[j];
a[j] = a[i];
a[i] = t;
}
}
}
Console.Write("{0}", a[0]);
for (int i = 1; i < a.Length; i++)
{
Console.Write("+{0}", a[i]);
}
}
}
}
+68
View File
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _378B
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a1 = new int[n];
int[] a2 = new int[n];
int i, j;
i = 0;
while (i < n)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
a1[i] = ip[0];
a2[i] = ip[1];
i++;
}
i = n / 2;
while (a1[i] < a2[n - 1 - i])
{
i++;
if (i == n)
{
break;
}
}
j = 0;
while (j < i)
{
Console.Write("1");
j++;
}
while (j < n)
{
Console.Write("0");
j++;
}
Console.WriteLine();
i = n / 2;
while (a2[i] < a1[n - 1 - i] && i < n)
{
i++;
if (i == n)
{
break;
}
}
j = 0;
while (j < i)
{
Console.Write("1");
j++;
}
while (j < n)
{
Console.Write("0");
j++;
}
}
}
}
+38
View File
@@ -0,0 +1,38 @@
using System;
namespace problem_381A
{
class problem_381A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] b = new int[n];
int l = 0, r = n - 1, s1 = 0, s2 = 0;
for (int i = 0; i < n; i++)
{
if (a[l] >= a[r])
{
b[i] = a[l++];
}
else
{
b[i] = a[r--];
}
}
for (int i = 0; i < n; i++)
{
if (i % 2 == 0)
{
s1 += b[i];
}
else
{
s2 += b[i];
}
}
Console.Write("{0} {1}", s1, s2);
}
}
}
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.Linq;
namespace problem_387B
{
class problem_387B
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int c = 0;
int i = a.Length - 1;
for (int j = b.Length - 1; i >= 0 && j >= 0; i--)
{
if (a[i] <= b[j])
{
j--;
}
else
{
c++;
}
}
if (i != -1)
{
c += i + 1;
}
Console.Write(c);
}
}
}
+50
View File
@@ -0,0 +1,50 @@
using System;
namespace problem_430A
{
class Program
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int max = 0;
for (int i = 1; i < ip[0]; i++)
{
if (a[i] != ip[2] || a[i - 1] != ip[2])
{
continue;
}
int l = i - 2, r = i + 1, cur = 2;
while (l >= 0 && r < ip[0])
{
int tmp = a[r];
int t = 0;
while (l >= 0 && a[l] == tmp)
{
l--;
t++;
}
while (r < ip[0] && a[r] == tmp)
{
r++;
t++;
}
if (t < 3)
{
break;
}
else
{
cur += t;
}
}
if (cur > max)
{
max = cur;
}
}
Console.Write(max);
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System;
namespace problem_43A
{
class problem_43A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
string t1 = Console.ReadLine();
string t2 = "";
int c1 = 1, c2 = 0;
for (int i = 1; i < n; i++)
{
string t = Console.ReadLine();
if (t == t1)
{
c1++;
}
else
{
t2 = t;
c2++;
}
}
if (c1 > c2)
{
Console.Write(t1);
}
else
{
Console.Write(t2);
}
}
}
}
+54
View File
@@ -0,0 +1,54 @@
using System;
namespace _448B
{
class Program
{
static void Main(string[] args)
{
string s1 = Console.ReadLine();
string s2 = Console.ReadLine();
char[] c1 = s1.ToCharArray();
char[] c2 = s2.ToCharArray();
Array.Sort(c1);
Array.Sort(c2);
if (Cnt(s1, s2) == s2.Length)
{
Console.WriteLine("automaton");
}
else if (new string(c1) == new string(c2))
{
Console.WriteLine("array");
}
else if (Cnt(new string(c1), new string(c2)) == s2.Length)
{
Console.WriteLine("both");
}
else
{
Console.WriteLine("need tree");
}
}
static int Cnt(string s1, string s2)
{
int id = 0, cnt = 0;
for (int i = 0; i < s2.Length; i++)
{
for (int j = id; j < s1.Length; j++)
{
if (s1[j] == s2[i])
{
id = j + 1;
cnt++;
break;
}
}
if (cnt == s2.Length)
{
break;
}
}
return cnt;
}
}
}
+57
View File
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _451B
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int i = 0, c = 0, l = 1, r = 1;
bool b = false;
while (i < n - 1)
{
if (a[i] < a[i + 1])
{
i++;
}
else
{
int j = i;
while (j < n - 1 && a[j] > a[j + 1])
{
j++;
}
l = i + 1;
r = j + 1;
c++;
i = r;
}
}
if (c < 2)
{
int c1 = l > 1 ? a[l - 2] : 0;
int c2 = r < n ? a[r] : int.MaxValue;
if (a[r - 1] > c1 && a[l - 1] < c2)
{
b = true;
}
}
if (b)
{
Console.WriteLine("yes");
Console.WriteLine("{0} {1}", l, r);
}
else
{
Console.WriteLine("no");
}
}
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
namespace _466A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int b = a[0] * a[2];
int c = (a[0] % a[1] == 0) ? a[0] / a[1] * a[3] : (a[0] / a[1] + 1) * a[3];
int d = a[0] / a[1] * a[3] + (a[0] % a[1]) * a[2];
Console.WriteLine(Math.Min(b, Math.Min(c, d)));
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
namespace _467A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int count = 0;
for (int i = 0; i < n; i++)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if (a[1] - a[0] > 1)
{
count++;
}
}
Console.WriteLine(count);
}
}
}
+38
View File
@@ -0,0 +1,38 @@
using System;
namespace problem_474A
{
class Program
{
static void Main(string[] args)
{
string s = "qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
string c = Console.ReadLine();
string ip = Console.ReadLine();
string op = "";
if (c == "R")
{
for (int i = 0; i < ip.Length; i++)
{
int p = s.IndexOf(ip[i]);
if (p != -1)
{
op += s[p - 1];
}
}
}
else
{
for (int i = 0; i < ip.Length; i++)
{
int p = s.IndexOf(ip[i]);
if (p != -1)
{
op += s[p + 1];
}
}
}
Console.WriteLine(op);
}
}
}
+18
View File
@@ -0,0 +1,18 @@
using System;
namespace _478A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int sum = 0;
for (int i = 0; i < 5; i++)
{
sum += a[i];
}
Console.WriteLine((sum % 5 == 0 && sum != 0) ? sum / 5 : -1);
}
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace _479A
{
class Program
{
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = int.Parse(Console.ReadLine());
Console.WriteLine(Math.Max(a + b + c, Math.Max(a * b * c, Math.Max(a + b * c, Math.Max(a * b + c, Math.Max((a + b) * c, a * (b + c)))))));
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace _486A
{
class Program
{
static void Main(string[] args)
{
ulong n = ulong.Parse(Console.ReadLine());
Console.WriteLine(n % 2 == 0 ? (n / 2).ToString() : "-" + ((n + 1) / 2).ToString());
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace _492A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int a = 0, b = 0, c = 0;
while (n > c)
{
a++;
b = a * (a + 1) / 2;
c += b;
}
Console.WriteLine(c > n ? a - 1 : a);
}
}
}
+38
View File
@@ -0,0 +1,38 @@
using System;
namespace _499B
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
bool[] b = new bool[a[1]];
string[] s1 = new string[a[1]];
string[] s2 = new string[a[1]];
for (int i = 0; i < a[1]; i++)
{
string[] ip = Console.ReadLine().Split(' ');
s1[i] = ip[0];
s2[i] = ip[1];
if (s2[i].Length < s1[i].Length)
{
b[i] = true;
}
}
string[] s = Console.ReadLine().Split(' ');
for (int i = 0; i < a[0]; i++)
{
int p = Array.IndexOf(s1, s[i]);
if (b[p])
{
s[i] = s2[p];
}
}
foreach (string t in s)
{
Console.Write("{0} ", t);
}
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace problem_4A
{
class problem_4A
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
if (n > 2 && n%2 == 0)
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace problem_50A
{
class problem_50A
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
Console.WriteLine("{0}", a[0] * a[1] / 2);
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using System;
namespace problem_510A
{
class problem_510A
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 0; i < ip[0]; i++)
{
switch (i % 4)
{
case 1:
for (int j = 1; j < ip[1]; j++)
{
Console.Write(".");
}
Console.WriteLine("#");
break;
case 3:
Console.Write("#");
for (int j = 1; j < ip[1]; j++)
{
Console.Write(".");
}
Console.WriteLine();
break;
default:
for (int j = 0; j < ip[1]; j++)
{
Console.Write("#");
}
Console.WriteLine();
break;
}
}
}
}
}
+56
View File
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _518A
{
class Program
{
static void Main(string[] args)
{
string c1 = Console.ReadLine();
string c2 = Console.ReadLine();
StringBuilder s1 = new StringBuilder(c1);
StringBuilder s2 = new StringBuilder(c2);
bool b;
if (s1.ToString() == s2.ToString())
{
b = false;
}
else
{
int j = s1.Length - 1;
for (; j >= 0; j--)
{
if (s1[j] == 'z')
{
s1[j] = 'a';
}
else
{
s1[j] = Convert.ToChar(s1[j] + 1);
break;
}
}
if (j == -1 || s1.ToString() == s2.ToString())
{
b = false;
}
else
{
b = true;
}
}
if (b)
{
Console.WriteLine(s1);
}
else
{
Console.WriteLine("No such string");
}
}
}
}
+44
View File
@@ -0,0 +1,44 @@
using System;
namespace _518B
{
class Program
{
static void Main(string[] args)
{
string s = Console.ReadLine();
string t = Console.ReadLine();
int[] c1 = new int[52];
int[] c2 = new int[52];
for (int i = 0; i < s.Length; i++)
{
if (char.IsLower(s[i]))
{
c1[s[i] - 'a']++;
}
else
{
c1[s[i] - 'A' + 26]++;
}
}
for (int i = 0; i < t.Length; i++)
{
if (char.IsLower(t[i]))
{
c2[t[i] - 'a']++;
}
else
{
c2[t[i] - 'A' + 26]++;
}
}
int y = 0, w = 0;
for (int i = 0; i < 26; i++)
{
y += Math.Min(c1[i], c2[i]) + Math.Min(c1[i + 26], c2[i + 26]);
w += Math.Min(Math.Max(c1[i] - c2[i], 0), Math.Max(c2[i + 26] - c1[i + 26], 0)) + Math.Min(Math.Max(c1[i + 26] - c2[i + 26], 0), Math.Max(c2[i] - c1[i], 0));
}
Console.WriteLine("{0} {1}", y, w);
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
namespace _520A
{
class Program
{
static string c = "abcdefghijklmnopqrstuvwxyz";
static bool Check(string s)
{
for (int i = 0; i < 26; i++)
{
if (s.IndexOf(c[i]) == -1)
{
return false;
}
}
return true;
}
static void Main(string[] args)
{
string s = Console.ReadLine();
s = Console.ReadLine().ToLower();
Console.WriteLine("{0}", Check(s) ? "YES" : "NO");
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace _546A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Console.WriteLine("{0}", Math.Max(a[0] * a[2] * (a[2] + 1) / 2 - a[1], 0));
}
}
}
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _557B
{
class Program
{
static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
double[] a = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
Array.Sort(a);
Console.WriteLine(Math.Min(ip[1], ip[0] * Math.Min(a[0] * 3, a[ip[0]] * 3 / 2)).ToString(".##########").Replace(",", "."));
}
}
}
+26
View File
@@ -0,0 +1,26 @@
using System;
using System.Linq;
namespace problem_572A
{
class problem_572A
{
public static void Main(string[] args)
{
int[] ip1 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] ip2 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] ip3 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] ip4 = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
Array.Sort(ip3);
Array.Sort(ip4);
if (ip3[ip2[0] - 1] < ip4[ip1[1] - ip2[1]])
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
}
}
+40
View File
@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _600B
{
class Program
{
static int FindFirstIndexGreaterThanOrEqualTo(ref List<int> sortedCollection, int key)
{
int begin = 0;
int end = sortedCollection.Count;
while (end > begin)
{
int index = (begin + end) / 2;
int el = sortedCollection[index];
if (el > key)
end = index;
else
begin = index + 1;
}
return end;
}
static void Main(string[] args)
{
string s = Console.ReadLine();
//int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
//int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
List<int> a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
List<int> b = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
a.Sort();
for (int i = 0; i < b.Count; i++)
{
Console.Write("{0} ", FindFirstIndexGreaterThanOrEqualTo(ref a, b[i]));
}
}
}
}
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Linq;
namespace _602B
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] b = a.ToArray();
int[] c = a.ToArray();
int c1 = 1, c2 = 1, max = 1;
for (int i = 0; i < n; i++)
{
if (a[i] % 2 == 1)
{
b[i]++;
}
else
{
c[i]++;
}
}
for (int i = 1; i < n; i++)
{
if (b[i] == b[i - 1])
{
c1++;
}
else
{
max = Math.Max(max, c1);
c1 = 1;
}
if (c[i] == c[i - 1])
{
c2++;
}
else
{
max = Math.Max(max, c2);
c2 = 1;
}
}
max = Math.Max(Math.Max(c1, c2), max);
Console.WriteLine(max);
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
namespace problem_609A
{
class problem_609A
{
public static void Main(string[] args)
{
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] a = new int[ip[1]];
int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 0; i < ip[0]; i++)
{
a[b[i] - 1]++;
}
long op = 0;
for (int i = 0; i < ip[1] - 1; i++)
{
for (int j = i + 1; j < ip[1]; j++)
{
op += a[i] * a[j];
}
}
Console.Write("{0}", op);
}
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace _617A
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
Console.WriteLine(n % 5 == 0 ? n / 5 : n / 5 + 1);
}
}
}
+35
View File
@@ -0,0 +1,35 @@
using System;
namespace _61B
{
class Program
{
static void Main(string[] args)
{
string[] c = new string[3];
for (int i = 0; i < 3; i++)
{
c[i] = Console.ReadLine().Replace("-", "").Replace(";", "").Replace("_", "").ToLower();
}
string s1 = c[0] + c[1] + c[2];
string s2 = c[0] + c[2] + c[1];
string s3 = c[1] + c[2] + c[0];
string s4 = c[1] + c[0] + c[2];
string s5 = c[2] + c[0] + c[1];
string s6 = c[2] + c[1] + c[0];
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
string s = Console.ReadLine().Replace("-", "").Replace(";", "").Replace("_", "").ToLower();
if (s == s1 || s == s2 || s == s3 || s == s4 || s == s5 || s == s6)
{
Console.WriteLine("ACC");
}
else
{
Console.WriteLine("WA");
}
}
}
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
namespace problem_673A
{
class problem_673A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int l = 15;
for (int i = 0; i < n; i++)
{
if (a[i] <= l)
{
l = a[i] + 15;
}
else
{
break;
}
}
l = Math.Min(l, 90);
Console.Write(l);
}
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Linq;
namespace problem_676A
{
class problem_676A
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int p1 = Array.IndexOf(a, a.Min());
int p2 = Array.IndexOf(a, a.Max());
Console.Write("{0}", new[] { p1, p2, n - 1 - p1, n - 1 - p2 }.Max());
}
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
namespace problem_691A
{
class problem_691A
{
public static void Main(string[] args)
{
Console.ReadLine();
string s = Console.ReadLine();
if ((s.IndexOf('0') == s.LastIndexOf('0') && s.Contains("0") && s.Contains("1")) || s == "1")
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
namespace _721B
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] l = new int[a[0]];
for (int i = 0; i < a[0]; i++)
{
l[i] = Console.ReadLine().Length;
}
int lp = Console.ReadLine().Length;
Array.Sort(l);
int p1 = Array.IndexOf(l, lp);
int p2 = Array.LastIndexOf(l, lp);
Console.Write("{0} {1}", p1 / a[1] * 5 + p1 + 1, p2 / a[1] * 5 + p2 + 1);
}
}
}
+25
View File
@@ -0,0 +1,25 @@
using System;
namespace _75A
{
class Program
{
static void Main(string[] args)
{
int a = int.Parse(Console.ReadLine());
int b = int.Parse(Console.ReadLine());
int c = a + b;
a = int.Parse(a.ToString().Replace("0", ""));
b = int.Parse(b.ToString().Replace("0", ""));
c = int.Parse(c.ToString().Replace("0", ""));
if (a + b == c)
{
Console.WriteLine("YES");
}
else
{
Console.WriteLine("NO");
}
}
}
}
+43
View File
@@ -0,0 +1,43 @@
using System;
namespace _787A
{
class Program
{
static void Main(string[] args)
{
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int[] b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if ((a[1] - b[1]) % GCD(a[0], b[0]) == 0)
{
while (a[1] != b[1])
{
if (a[1] < b[1])
{
a[1] += a[0];
}
else
{
b[1] += b[0];
}
}
Console.WriteLine(a[1]);
}
else
{
Console.WriteLine(-1);
}
}
static int GCD(int a, int b)
{
int t;
while (b != 0)
{
t = a % b;
a = b;
b = t;
}
return a;
}
}
}
+43
View File
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _879B
{
class Program
{
static void Main(string[] args)
{
long[] ip = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
if (ip[0] <= ip[1])
{
Console.Write("{0}", a.Max());
}
else
{
int c = 0;
int t = a[0];
for (int i = 1; i < ip[0]; i++)
{
if (c == ip[1])
{
break;
}
if (t > a[i])
{
c++;
}
else
{
c = 1;
t = a[i];
}
}
Console.Write(t);
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
using System.Linq;
using System.Collections.Generic;
namespace problem_961A
{
class problem_961A
{
static void Main(string[] args)
{
int[] ip1 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] ip2 = Console.ReadLine().Split().Select(int.Parse).ToArray();
int[] a = new int[ip1[0]];
for (int i = 0; i < ip1[1]; i++)
{
a[ip2[i] - 1]++;
}
Console.Write("{0}", a.Min());
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
namespace problem_96A
{
public class problem_96A
{
public static void Main(string[] args)
{
string s = Console.ReadLine();
if (s.Contains("0000000") || s.Contains("1111111"))
{
Console.Write("YES");
}
else
{
Console.Write("NO");
}
}
}
}
+112
View File
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace problem_993E
{
class problem_993E
{
public static void Main(string[] args)
{
const double pi = 3.14159265359;
const int N = 800005;
int n, m, x, l, L = 0;
int[] s = new int[N];
int[] R = new int[N];
int[] c = new int[N];
C[] a = new C[N];
C[] b = new C[N];
int[] ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
n = ip[0];
x = ip[1];
c[0]++;
ip = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
for (int i = 1; i <= n; i++)
{
s[i] = s[i - 1] + Convert.ToInt32(ip[i - 1] < x);
c[s[i]]++;
}
for (int i = 0; i <= n; i++)
{
a[i].r = c[i];
b[i].r = c[n - i];
}
m = (n << 1);
for (l = 1; l <= m; l <<= 1)
{
L++;
}
for (int i = 0; i < l; i++)
{
R[i] = (R[i >> 1] >> 1| ((i & 1) << (L - 1)));
}
F(a, 1, l, R, pi);
F(b, 1, l, R, pi);
for (int i = 0; i < l; i++)
{
a[i] *= b[i];
}
F(a, -1, l, R, pi);
Console.Write("{0}", (long)(a[n].r / l + 0.5 - n) >> 1);
for (int i = 1; i <= n; i++)
{
Console.Write(" {0}", (long)(a[i + n].r / l + 0.5));
}
}
public static void F(C[] A, int o, int l, int[] R, double pi)
{
for (int i = 0; i < l; i++)
{
if (i < R[i])
{
S(A, i, R[i]);
}
}
for (int i = 1; i < l; i <<= 1)
{
C x, y, wn = new C(Math.Cos(pi / i), Math.Sin(pi * o / i));
for (int j = 0; j < l; j += (i << 1))
{
C w = new C(1, 0);
for (int k = 0; k < i; k++, w *= wn)
{
x = A[j + k];
y = w * A[j + k + i];
A[j + k] = x + y;
A[j + k + i] = x - y;
}
}
}
}
public static void S(C[] A, int p1, int p2)
{
C t = A[p1];
A[p1] = A[p2];
A[p2] = t;
}
}
public struct C
{
public double r;
public double i;
public C(double r, double i)
{
this.r = r;
this.i = i;
}
public static C operator + (C l, C r)
{
return new C(l.r + r.r, l.i + r.i);
}
public static C operator - (C l, C r)
{
return new C(l.r - r.r, l.i - r.i);
}
public static C operator * (C l, C r)
{
return new C(l.r * r.r - l.i * r.i, l.r * r.i + l.i * r.r);
}
}
}
+22
View File
@@ -0,0 +1,22 @@
using System;
namespace problem_996A
{
class problem_996A
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = { 1, 5, 10, 20, 100 };
int i = 4;
int s = 0;
while (n > 0 && i >= 0)
{
s += n / a[i];
n %= a[i];
i--;
}
Console.Write(s);
}
}
}
+32
View File
@@ -0,0 +1,32 @@
using System;
namespace problem_996B
{
class problem_996B
{
public static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
int m = a[0];
for (int i = 1; i < n; i++)
{
if (a[i] < m)
{
m = a[i];
}
}
int p = m % n;
while (a[p] > m)
{
m++;
p++;
if (p == n)
{
p = 0;
}
}
Console.Write("{0}", p + 1);
}
}
}
+37
View File
@@ -0,0 +1,37 @@
using System;
namespace problem_999A
{
class problem_999A
{
static void Main(string[] args)
{
string[] input = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(input[0]);
int k = Convert.ToInt32(input[1]);
input = Console.ReadLine().Split(' ');
int[] a = new int[n];
int i;
for (i = 0; i < n; i++)
{
a[i] = Convert.ToInt32(input[i]);
}
i = 0;
int l = 0;
while (i < n && a[i] <= k)
{
l++;
i++;
}
i = n - 1;
int r = 0;
while (i >= 0 && a[i] <= k)
{
r++;
i--;
}
int ouput = Math.Min(l + r, n);
Console.WriteLine(ouput);
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
namespace problem_999B
{
class problem_999B
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
for (int i = 1; i <= n; i++)
{
if (n%i == 0)
{
s = Reverse(s.Substring(0, i)) + s.Substring(i);
}
}
Console.Write(s);
}
public static string Reverse(string s)
{
char[] a = s.ToCharArray();
char[] b = new char[s.Length];
for (int i = 0; i < s.Length; i++)
{
b[i] = a[s.Length - 1 - i];
}
return new string(b);
}
}
}