Submission #675675

#TimeUsernameProblemLanguageResultExecution timeMemory
675675a_aguiloExam (eJOI20_exam)C++14
12 / 100
76 ms1100 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int A[n]; int B[n]; for(int i = 0; i < n; ++i) cin >> A[i]; for(int i = 0; i < n; ++i) cin >> B[i]; queue<int> Q; int counter = 0; for(int i = 0; i < n; ++i){ if(A[i] == B[i]) Q.push(i); } while(!Q.empty()){ int actPos = Q.front(); Q.pop(); if(A[actPos] == B[actPos]) counter++; else continue; if(actPos > 0){ if(A[actPos-1] != B[actPos] and A[actPos-1]<A[actPos]){ A[actPos-1] = B[actPos]; Q.push(actPos-1); } } if(actPos < (n-1)){ if(A[actPos+1] != B[actPos] and A[actPos+1]<A[actPos]){ A[actPos+1] = B[actPos]; Q.push(actPos+1); } } } cout << counter<< endl; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...