Skip to content

Instantly share code, notes, and snippets.

@aratak
Last active December 15, 2015 03:29
Show Gist options
  • Save aratak/5194268 to your computer and use it in GitHub Desktop.
Save aratak/5194268 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace drawwell
{
class Program
{
static public int f()
{
string[] t1;
string[] t2;
StreamReader sr = new StreamReader("data.txt");
t1 = sr.ReadLine().Split(' ');
t2 = sr.ReadLine().Split(' ');
int[] a = new int[t1.Length];
int[] b = new int[t2.Length];
for (int i = 0; i < t1.Length; i++)
{
a[i] = Convert.ToInt32(t1[i]);
}
for (int i = 0; i < t2.Length; i++)
{
b[i] = Convert.ToInt32(t2[i]);
}
int height = a.Length; //Кол-во элементов
int curp = height; //Позиция заполнения current position
int curdisc = 0; //Текущее кольцо для бросания
int count = 0; //Кол-во колец в колодце
if ((b.Length == 1) && (b[0] < a[0]))
{
return 1;
}
else
{
while ((curp > 0)&&(curdisc<b.Length))
{
for (int i = 0; i < curp; i++)
{
if ((a[i] < b[curdisc]) || ((i + 1) == curp))
{
if (a[i] < b[curdisc])
{
if (i != 0)
curp = i - 1;
else
return count;
}
else
{
curp = i;
}
count++;
curdisc++;
}
}
}
}
return count;
}
static void Main(string[] args)
{
int count = f();
Console.WriteLine(count);
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment