A. Olympiad Date

time limit per test

1 second

memory limit per test

256 megabytes

The final of the first Olympiad by IT Campus "NEIMARK" is scheduled for March 1, 2025. A nameless intern was tasked with forming the date of the Olympiad using digits --- 01.03.2025.

To accomplish this, the intern took a large bag of digits and began drawing them one by one. In total, he drew nn digits --- the digit aiai was drawn in the ii-th turn.

You suspect that the intern did extra work. Determine at which step the intern could have first assembled the digits to form the date of the Olympiad (the separating dots can be ignored), or report that it is impossible to form this date from the drawn digits. Note that leading zeros must be displayed.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041≤t≤104). The description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤201≤n≤20).

The second line of each test case contains nn integers aiai (0≤ai≤90≤ai≤9) --- the numbers that the intern pulled out in chronological order.

Output

For each test case, output the minimum number of digits that the intern could pull out. If all the digits cannot be used to make a date, output the number 00.

Example

Input

Copy

复制代码

4

10

2 0 1 2 3 2 5 0 0 1

8

2 0 1 2 3 2 5 0

8

2 0 1 0 3 2 5 0

16

2 3 1 2 3 0 1 9 2 1 0 3 5 4 0 3

Output

Copy

复制代码
9
0
8
15

解题说明:水题,直接遍历数组判断是否找出所需要的所有数字即可。

cpp 复制代码
#include <iostream>
#include<algorithm>
using namespace std;

int main()
{
	int  t = 1;
	cin >> t;
	while (t--) 
	{
		int n = 0;
		cin >> n;
		int a[21];
		int mp[11] = {0};
		int ans = 0;
		for (int i = 1; i <= n; i++)
		{
			cin >> a[i];
			mp[a[i]]++;
			if (mp[0] >= 3 && mp[1] >= 1 && mp[2] >= 2 && mp[3] >= 1 && mp[5] >= 1 && ans == 0)
			{
				ans = i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
相关推荐
帅中的小灰灰1 分钟前
C++编程观察者设计模式
数据库·c++·设计模式
小白程序员成长日记27 分钟前
2025.11.21 力扣每日一题
算法·leetcode·职场和发展
MSTcheng.1 小时前
【C++STL】priority_queue 模拟实现与仿函数实战
开发语言·c++
还有几根头发呀1 小时前
从 C++ 的角度,系统地解释 进程(Process)、线程(Thread)、协程(Coroutine) 的概念、原理、优缺点,以及常见应用场景。
c++
oioihoii1 小时前
Python与C++:从哲学到细节的全面对比
c++
小年糕是糕手1 小时前
【C++】C++入门 -- inline、nullptr
linux·开发语言·jvm·数据结构·c++·算法·排序算法
高洁011 小时前
具身智能-普通LLM智能体与具身智能:从语言理解到自主行动
人工智能·深度学习·算法·aigc·知识图谱
kk哥88991 小时前
Keil MDK 5.39 编程 + 调试 ,ARM 嵌入式开发!如何安装
c++·arm
重启的码农2 小时前
enet源码解析 (2) 对等节点 (ENetPeer)
c++·网络协议
星期天22 小时前
3.2联合体和枚举enum,还有动态内存malloc,free,calloc,realloc
c语言·开发语言·算法·联合体·动态内存·初学者入门·枚举enum