Submission #00006
ソースコード
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 | #include<bits/stdc++.h> using namespace std; int dp[5001][5002]; int main(){ int a,b; int red[5001],blue[5001]; scanf ( "%d %d" ,&a,&b); for ( int i=1;i<=a;i++){ scanf ( "%d" ,&red[i]); } for ( int i=1;i<=b;i++){ scanf ( "%d" ,&blue[i]); } for ( int i=0;i<5002;i++) dp[0][i] = 0; for ( int i=1;i<=a;i++){ for ( int j=1;j<=b;j++){ dp[i][j] = dp[i-1][j]; if (red[i] == blue[j]){ if (j == 1 || dp[i-1][j-1] != 0) dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1); if (j == b || dp[i-1][j+1] != 0) dp[i][j] = max(dp[i][j],dp[i-1][j+1]+1); } //printf("%3d",dp[i][j]); } //putchar('\n'); } int ans = 0; for ( int i=0;i<b;i++) ans = max(ans,dp[a][i]); printf ( "%d\n" ,ans); return (0); } |
ステータス
項目 | データ |
---|---|
問題 | 0001 - 楽しいカードゲーム |
ユーザー名 | ei1626 |
投稿日時 | 2018-01-24 16:59:01 |
言語 | C++ |
状態 | Wrong Answer |
得点 | 0 |
ソースコード長 | 755 Byte |
最大実行時間 | 57 ms |
最大メモリ使用量 | 98476 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | INPUT1 | 0 / 10 | 01-*.txt |
2 | INPUT2 | 0 / 10 | 02-*.txt |
3 | INPUT3 | 0 / 10 | 03-*.txt |
4 | INPUT4 | 0 / 10 | 04-*.txt |
5 | INPUT5 | 0 / 10 | 05-*.txt |
6 | INPUT6 | 0 / 10 | 06-*.txt |
7 | INPUT7 | 0 / 10 | 07-*.txt |
8 | INPUT8 | 0 / 10 | 08-*.txt |
9 | INPUT9 | 0 / 10 | 09-*.txt |
10 | INPUT10 | 0 / 10 | 10-*.txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
01-01.txt | WA | 49 ms | 480 KB |
1
|
|||||||||
01-02.txt | WA | 24 ms | 392 KB |
1
|
|||||||||
02-01.txt | WA | 17 ms | 812 KB |
2
|
|||||||||
02-02.txt | WA | 19 ms | 840 KB |
2
|
|||||||||
03-01.txt | WA | 20 ms | 868 KB |
3
|
|||||||||
03-02.txt | WA | 17 ms | 896 KB |
3
|
|||||||||
04-01.txt | WA | 20 ms | 960 KB |
4
|
|||||||||
04-02.txt | WA | 20 ms | 904 KB |
4
|
|||||||||
05-01.txt | WA | 18 ms | 944 KB |
5
|
|||||||||
05-02.txt | AC | 16 ms | 976 KB |
5
|
|||||||||
06-01.txt | AC | 56 ms | 96740 KB |
6
|
|||||||||
06-02.txt | WA | 45 ms | 97204 KB |
6
|
|||||||||
06-03.txt | WA | 55 ms | 98192 KB |
6
|
|||||||||
06-04.txt | WA | 50 ms | 98084 KB |
6
|
|||||||||
07-01.txt | WA | 47 ms | 96824 KB |
7
|
|||||||||
07-02.txt | WA | 53 ms | 98024 KB |
7
|
|||||||||
07-03.txt | WA | 47 ms | 98200 KB |
7
|
|||||||||
07-04.txt | WA | 53 ms | 98224 KB |
7
|
|||||||||
08-01.txt | WA | 57 ms | 97728 KB |
8
|
|||||||||
08-02.txt | WA | 54 ms | 98076 KB |
8
|
|||||||||
08-03.txt | WA | 47 ms | 98308 KB |
8
|
|||||||||
08-04.txt | WA | 51 ms | 98328 KB |
8
|
|||||||||
09-01.txt | WA | 49 ms | 98352 KB |
9
|
|||||||||
09-02.txt | WA | 48 ms | 97772 KB |
9
|
|||||||||
09-03.txt | WA | 50 ms | 98396 KB |
9
|
|||||||||
09-04.txt | WA | 50 ms | 98420 KB |
9
|
|||||||||
10-01.txt | WA | 47 ms | 97924 KB |
10
|
|||||||||
10-02.txt | WA | 47 ms | 97528 KB |
10
|
|||||||||
10-03.txt | WA | 51 ms | 98456 KB |
10
|
|||||||||
10-04.txt | WA | 47 ms | 98476 KB |
10
|