Submission #3419852
Source Code Expand
#include<bits/stdc++.h> using namespace std; int dp[110][2]; int arr[110]; int n; int rec(int p,int f) { if(p==n+1) return 0; int &ret=dp[p][f]; if(ret!=-1) return ret; ret=100000; if(f==1) { ret=min(ret,1+rec(p+1,1)); ret=min(ret,rec(p+1,0)); } else { if(arr[p]!=arr[p-1]) ret=min(ret,rec(p+1,0)); ret=min(ret,1+rec(p+1,1)); } return ret; } int main() { cin >> n; for(int i=1; i<=n; i++) cin >> arr[i]; memset(dp,-1,sizeof dp); int ret=min(1+rec(2,1),rec(2,0)); cout<<ret<<endl; }
Submission Info
Submission Time | |
---|---|
Task | A - Colorful Slimes 2 |
User | vjudge2 |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 580 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example_0, example_1, example_2, example_3 |
All | example_0, example_1, example_2, example_3, handmade_0, handmade_1, rand_0, rand_1, smallcolor_0, smallcolor_1, smallcolor_2, smallcolor_3, smallcolor_4 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
example_0 | AC | 1 ms | 256 KB |
example_1 | AC | 1 ms | 256 KB |
example_2 | AC | 1 ms | 256 KB |
example_3 | AC | 1 ms | 256 KB |
handmade_0 | AC | 1 ms | 256 KB |
handmade_1 | AC | 1 ms | 256 KB |
rand_0 | AC | 1 ms | 256 KB |
rand_1 | AC | 1 ms | 256 KB |
smallcolor_0 | AC | 1 ms | 256 KB |
smallcolor_1 | AC | 1 ms | 256 KB |
smallcolor_2 | AC | 1 ms | 256 KB |
smallcolor_3 | AC | 1 ms | 256 KB |
smallcolor_4 | AC | 1 ms | 256 KB |