Submission #997917


Source Code Expand

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue - 10;
	const long INFL = long.MaxValue - 10;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;
	

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int N = cin.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
		{
			A[i] = cin.nextInt();
		}
		string S = cin.next();

		int M = S.Length, m = 0;
		for (int i = 0; i < S.Length; i++)
		{
			if (S[i] == 'm')
			{
				M = i;
				m = S.Length - i;
				break;
			}
		}
		SegTreeMax sgM = new SegTreeMax(A);
		int[] B = new int[N - M];
		for (int i = 0; i < N - M; i++)
		{
			B[i] = sgM.rmq(i, i + M + 1);
			//Console.WriteLine(B[i]);
		}
		//SegTreeMin sgm = new SegTreeMin(B);
		Console.WriteLine(B.Min());
	}
	class SegTreeMin
	{
		int n;  // 葉ノードの数
		int[] dat;

		// 区間[a,b)の最小値。ノードk=[l,r)に着目している。
		public int _rmq(int a, int b, int k, int l, int r)
		{
			if (r <= a || b <= l) return INF; // 交差しない
			if (a <= l && r <= b) return dat[k];    //a,l,r,bの順 
			else {
				int s1 = _rmq(a, b, 2 * k + 1, l, (l + r) / 2);
				int s2 = _rmq(a, b, 2 * k + 2, (l + r) / 2, r);
				return Math.Min(s1, s2);
			}
		}

		public int rmq(int a, int b)
		{
			return _rmq(a, b, 0, 0, n);
		}

		public void update(int k, int x)
		{
			k += n - 1;
			dat[k] = x;
			while (k > 0)
			{
				k = (k - 1) / 2;
				dat[k] = Math.Min(dat[2 * k + 1], dat[2 * k + 2]);
			}
		}

		public SegTreeMin(int size)
		{
			n = 1;
			while (n < size) n <<= 1;
			dat = new int[n << 1];
		}

		public SegTreeMin(int[] array)
		{
			n = 1;
			while (n < array.Length) n <<= 1;
			dat = new int[2 * n - 1];
			for (int i = 0; i < array.Length; i++)
			{
				dat[i + n - 1] = array[i];
			}
			for (int i = array.Length; i < n; i++)
			{
				dat[i + n - 1] = INF;
			}
			for (int i = n - 2; i >= 0; i--)
			{
				dat[i] = Math.Min(dat[2 * i + 1], dat[2 * i + 2]);
			}
		}
	}
	class SegTreeMax
	{
		int n;  // 葉ノードの数
		int[] dat;

		// 区間[a,b)の最小値。ノードk=[l,r)に着目している。
		public int _rmq(int a, int b, int k, int l, int r)
		{
			if (r <= a || b <= l) return 0; // 交差しない
			if (a <= l && r <= b) return dat[k];    //a,l,r,bの順 
			else {
				int s1 = _rmq(a, b, 2 * k + 1, l, (l + r) / 2);
				int s2 = _rmq(a, b, 2 * k + 2, (l + r) / 2, r);
				return Math.Max(s1, s2);
			}
		}

		public int rmq(int a, int b)
		{
			return _rmq(a, b, 0, 0, n);
		}

		public void update(int k, int x)
		{
			k += n - 1;
			dat[k] = x;
			while (k > 0)
			{
				k = (k - 1) / 2;
				dat[k] = Math.Max(dat[2 * k + 1], dat[2 * k + 2]);
			}
		}

		public SegTreeMax(int size)
		{
			n = 1;
			while (n < size) n <<= 1;
			dat = new int[n << 1];
		}

		public SegTreeMax(int[] array)
		{
			n = 1;
			while (n < array.Length) n <<= 1;
			dat = new int[2 * n - 1];
			for (int i = 0; i < array.Length; i++)
			{
				dat[i + n - 1] = array[i];
			}
			for (int i = array.Length; i < n; i++)
			{
				dat[i + n - 1] = 0;
			}
			for (int i = n - 2; i >= 0; i--)
			{
				dat[i] = Math.Max(dat[2 * i + 1], dat[2 * i + 2]);
			}
		}
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Submission Info

Submission Time
Task B - Compression
User furuya1223
Language C# (Mono 4.6.2.0)
Score 400
Code Size 4389 Byte
Status WA
Exec Time 92 ms
Memory 12120 KB

Judge Result

Set Name Sample subtask1 subtask2 All
Score / Max Score 0 / 0 400 / 400 0 / 800 0 / 200
Status
AC × 1
WA × 3
AC × 13
AC × 4
WA × 9
AC × 20
WA × 29
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt
subtask1 sample_2.txt, subtask_1.2_1.txt, subtask_1.2_2.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt
subtask2 sample_1.txt, subtask_1.2_1.txt, subtask_1.2_2.txt, subtask_2_1.txt, subtask_2_10.txt, subtask_2_2.txt, subtask_2_3.txt, subtask_2_4.txt, subtask_2_5.txt, subtask_2_6.txt, subtask_2_7.txt, subtask_2_8.txt, subtask_2_9.txt
All sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, 2_1.txt, 2_2.txt, subtask_1.2_1.txt, subtask_1.2_2.txt, subtask_1_1.txt, subtask_1_10.txt, subtask_1_2.txt, subtask_1_3.txt, subtask_1_4.txt, subtask_1_5.txt, subtask_1_6.txt, subtask_1_7.txt, subtask_1_8.txt, subtask_1_9.txt, subtask_2_1.txt, subtask_2_10.txt, subtask_2_2.txt, subtask_2_3.txt, subtask_2_4.txt, subtask_2_5.txt, subtask_2_6.txt, subtask_2_7.txt, subtask_2_8.txt, subtask_2_9.txt, subtask_3_1.txt, subtask_3_10.txt, subtask_3_11.txt, subtask_3_12.txt, subtask_3_13.txt, subtask_3_14.txt, subtask_3_15.txt, subtask_3_16.txt, subtask_3_17.txt, subtask_3_18.txt, subtask_3_19.txt, subtask_3_2.txt, subtask_3_20.txt, subtask_3_21.txt, subtask_3_3.txt, subtask_3_4.txt, subtask_3_5.txt, subtask_3_6.txt, subtask_3_7.txt, subtask_3_8.txt, subtask_3_9.txt
Case Name Status Exec Time Memory
2_1.txt AC 22 ms 2904 KB
2_2.txt AC 20 ms 2776 KB
sample_1.txt WA 21 ms 2776 KB
sample_2.txt AC 20 ms 2776 KB
sample_3.txt WA 20 ms 2776 KB
sample_4.txt WA 20 ms 2776 KB
subtask_1.2_1.txt AC 20 ms 2776 KB
subtask_1.2_2.txt AC 20 ms 2776 KB
subtask_1_1.txt AC 92 ms 11992 KB
subtask_1_10.txt AC 77 ms 11864 KB
subtask_1_2.txt AC 65 ms 11736 KB
subtask_1_3.txt AC 60 ms 11736 KB
subtask_1_4.txt AC 65 ms 10968 KB
subtask_1_5.txt AC 29 ms 4056 KB
subtask_1_6.txt AC 85 ms 11864 KB
subtask_1_7.txt AC 20 ms 2776 KB
subtask_1_8.txt AC 79 ms 11864 KB
subtask_1_9.txt AC 78 ms 11864 KB
subtask_2_1.txt WA 82 ms 11992 KB
subtask_2_10.txt WA 82 ms 12120 KB
subtask_2_2.txt WA 82 ms 12120 KB
subtask_2_3.txt WA 83 ms 12120 KB
subtask_2_4.txt WA 83 ms 12120 KB
subtask_2_5.txt AC 20 ms 2776 KB
subtask_2_6.txt AC 20 ms 2776 KB
subtask_2_7.txt WA 20 ms 2776 KB
subtask_2_8.txt WA 81 ms 11864 KB
subtask_2_9.txt WA 35 ms 5336 KB
subtask_3_1.txt WA 82 ms 12120 KB
subtask_3_10.txt WA 84 ms 12120 KB
subtask_3_11.txt WA 83 ms 11992 KB
subtask_3_12.txt AC 83 ms 11992 KB
subtask_3_13.txt WA 82 ms 11992 KB
subtask_3_14.txt WA 82 ms 12120 KB
subtask_3_15.txt AC 82 ms 12120 KB
subtask_3_16.txt AC 81 ms 12120 KB
subtask_3_17.txt WA 85 ms 12120 KB
subtask_3_18.txt WA 84 ms 12120 KB
subtask_3_19.txt WA 85 ms 11992 KB
subtask_3_2.txt WA 82 ms 11992 KB
subtask_3_20.txt WA 86 ms 11992 KB
subtask_3_21.txt WA 83 ms 11992 KB
subtask_3_3.txt WA 27 ms 4056 KB
subtask_3_4.txt WA 76 ms 11224 KB
subtask_3_5.txt WA 70 ms 10456 KB
subtask_3_6.txt WA 82 ms 11992 KB
subtask_3_7.txt WA 82 ms 12120 KB
subtask_3_8.txt WA 83 ms 11992 KB
subtask_3_9.txt WA 82 ms 11992 KB