-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWmil.java
More file actions
83 lines (78 loc) · 1.8 KB
/
Wmil.java
File metadata and controls
83 lines (78 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.io.*;
import java.util.*;
class Wmil
{
int t,n;
String q,s;
int ot=0;
int in[],out[];
void input()throws java.io.IOException
{
//Scanner sc=new Scanner(System.in);
java.io.InputStreamReader ir=new java.io.InputStreamReader(System.in);
java.io.BufferedReader br=new java.io.BufferedReader(ir);
t=Integer.parseInt(br.readLine());
out=new int[t];
for(int i=0;i<t;i++)
{
n=Integer.parseInt(br.readLine());
q=br.readLine();
s=br.readLine();
in=new int[n+1];
String str=br.readLine()+" ";
String st1="";
int k=0;
for(int j=0;j<str.length();j++)
{
char c=str.charAt(j);
if(c==' ')
{
in[k]=Integer.parseInt(st1);
k++;
st1="";
}
else
st1=st1+c;
}
chk();
out[i]=ot;
ot=0;
}
for(int i=0;i<t;i++)
{
System.out.println(out[i]);
}
}
void chk()
{
int c=0;
if(q.equalsIgnoreCase(s)==true)
{
ot=in[n];
return;
}
c++;
int z=0;
for(int i=0;i<n;i++)
{
char e=s.charAt(i);
char f=q.charAt(i);
if(e==f)
{
z++;
}
}
ot=in[0];
for(int i=1;i<=z;i++)
{
if(ot<=in[i])
ot=in[i];
}
return;
}
public static void main(String args[])throws java.io.IOException
{
Wmil ob=new Wmil();
ob.input();
}
}