Submission #1735805


Source Code Expand

#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m,a[5010],b[5010];

int main(){
	cin >> n >> m;
	REP(i,0,n) cin >> a[i];
	REP(i,0,m) cin >> b[i];
	
	int ma=0;
	REP(i,0,m){
		int x=i,c=0;
		REP(j,0,n){
			if(a[j]==b[x]) x++,c++;
			if(x>=m) break;
		}
		
		ma=max(ma,c);
	}
	
	cout << ma << endl;
	return 0;
}

Submission Info

Submission Time
Task B - たのしいカードゲーム (Card Game is Fun)
User ecasdqina
Language C++14 (GCC 5.4.1)
Score 100
Code Size 596 Byte
Status AC
Exec Time 33 ms
Memory 384 KB

Judge Result

Set Name set01 set02 set03 set04 set05 set06 set07 set08 set09 set10
Score / Max Score 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10 10 / 10
Status
AC × 2
AC × 2
AC × 2
AC × 2
AC × 2
AC × 4
AC × 4
AC × 4
AC × 4
AC × 4
Set Name Test Cases
set01 01-01.txt, 01-02.txt
set02 02-01.txt, 02-02.txt
set03 03-01.txt, 03-02.txt
set04 04-01.txt, 04-02.txt
set05 05-01.txt, 05-02.txt
set06 06-01.txt, 06-02.txt, 06-03.txt, 06-04.txt
set07 07-01.txt, 07-02.txt, 07-03.txt, 07-04.txt
set08 08-01.txt, 08-02.txt, 08-03.txt, 08-04.txt
set09 09-01.txt, 09-02.txt, 09-03.txt, 09-04.txt
set10 10-01.txt, 10-02.txt, 10-03.txt, 10-04.txt
Case Name Status Exec Time Memory
01-01.txt AC 1 ms 256 KB
01-02.txt AC 1 ms 256 KB
02-01.txt AC 1 ms 256 KB
02-02.txt AC 1 ms 256 KB
03-01.txt AC 1 ms 256 KB
03-02.txt AC 1 ms 256 KB
04-01.txt AC 1 ms 256 KB
04-02.txt AC 1 ms 256 KB
05-01.txt AC 1 ms 256 KB
05-02.txt AC 1 ms 256 KB
06-01.txt AC 28 ms 256 KB
06-02.txt AC 31 ms 256 KB
06-03.txt AC 30 ms 256 KB
06-04.txt AC 29 ms 256 KB
07-01.txt AC 27 ms 256 KB
07-02.txt AC 30 ms 256 KB
07-03.txt AC 31 ms 256 KB
07-04.txt AC 29 ms 256 KB
08-01.txt AC 28 ms 256 KB
08-02.txt AC 30 ms 256 KB
08-03.txt AC 30 ms 256 KB
08-04.txt AC 29 ms 256 KB
09-01.txt AC 28 ms 256 KB
09-02.txt AC 31 ms 256 KB
09-03.txt AC 30 ms 256 KB
09-04.txt AC 29 ms 256 KB
10-01.txt AC 28 ms 256 KB
10-02.txt AC 33 ms 384 KB
10-03.txt AC 32 ms 256 KB
10-04.txt AC 29 ms 256 KB