Submission #1164562

#TimeUsernameProblemLanguageResultExecution timeMemory
1164562PwoMoney (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 = a[n], j = n; while (j >= 0) { if (c == 0 || c != a[j]) ans++; if (j == 0) break; 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...