제출 #1127562

#제출 시각아이디문제언어결과실행 시간메모리
1127562khanhphucscratchExam (eJOI20_exam)C++20
12 / 100
21 ms1864 KiB
//Subtask 2 #include<bits/stdc++.h> using namespace std; int a[100005], b[100005], firstval[100005], lastval[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(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]; int target = b[1]; for(int i = 1; i <= n; i++){ if(a[i] >= target) firstval[i] = a[i]; else firstval[i] = firstval[i-1]; } for(int i = n; i >= 1; i--){ if(a[i] >= target) lastval[i] = a[i]; else lastval[i] = lastval[i+1]; } int ans = 0; for(int i = 1; i <= n; i++) if(lastval[i] == target || firstval[i] == target) ans++; cout<<ans; }
#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...