제출 #833679

#제출 시각아이디문제언어결과실행 시간메모리
833679vjudge1Exam (eJOI20_exam)C++17
12 / 100
17 ms1220 KiB
#include <bits/stdc++.h> using namespace std; vector<int>h, t; vector<bool>vis; int n; int d[] = {-1, 1}; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; h.resize(n + 1); t.resize(n + 1); vis.resize(n + 1, 0); for(int i = 1; i <= n; i++) cin >> h[i]; for(int i = 1; i <= n; i++) cin >> t[i]; queue<int>q; int x = t[1]; int ans = 0; for(int i = 1; i <= n; i++){ if(h[i] == x){ q.push(i); ans++; vis[i] = true; } } while(!q.empty()){ int cur = q.front(); q.pop(); for(int i = 0; i < 2; i++){ int nxt = cur + d[i]; if(nxt > 0 && nxt <= n && h[nxt] < x && !vis[nxt]){ vis[nxt] = true; q.push(nxt); ans++; } } } cout << ans << '\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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...