제출 #1164554

#제출 시각아이디문제언어결과실행 시간메모리
1164554PwoMoney (IZhO17_money)C++20
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, a[1000005], p[1000005]; int find(int v) { if (p[v] == v) return v; return p[v] = find(p[v]); } int32_t main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; p[i] = i; } int ans = 0; int c = 0, j = n; while (j >= 1) { if (c == 0 || c != a[j]) ans++; c = find(a[j] - 1); p[a[j]] = c; j--; } 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...