제출 #941909

#제출 시각아이디문제언어결과실행 시간메모리
941909maxFedorchukLamps (JOI19_lamps)C++17
4 / 100
28 ms35676 KiB
#include <bits/stdc++.h> using namespace std; const long long MX=1e6+10; const long long INF=1e18; long long dp[MX][4]; char a[MX],b[MX]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; } for(int i=1;i<=n;i++) { cin>>b[i]; } dp[0][0]=0; dp[0][1]=dp[0][2]=dp[0][3]=INF; for(int i=1;i<=n;i++) { dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=INF; if(a[i]==b[i]) { dp[i][0]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2],dp[i-1][3]}); } else { dp[i][3]=min({dp[i-1][0]+1,dp[i-1][1]+1,dp[i-1][2]+1,dp[i-1][3]}); } if(b[i]=='0') { dp[i][1]=min({dp[i-1][0]+1,dp[i-1][1],dp[i-1][2]+1,dp[i-1][3]+1}); } else { dp[i][2]=min({dp[i-1][0]+1,dp[i-1][1]+1,dp[i-1][2],dp[i-1][3]+1}); } } cout<<min({dp[n][0],dp[n][1],dp[n][2],dp[n][3]})<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...