Submission #966527

#TimeUsernameProblemLanguageResultExecution timeMemory
966527yellowtoadMoney (IZhO17_money)C++17
0 / 100
1 ms348 KiB
#include <iostream> #include <set> using namespace std; int n, a[1000010], cnt; set<int> bst; set<int>::iterator iter; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { if (a[i-1] > a[i]) cnt++; else { iter = bst.upper_bound(a[i-1]); if ((iter != bst.end()) && (*iter < a[i])) cnt++; } bst.insert(a[i]); } cout << cnt+1 << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...