Submission #382825

#TimeUsernameProblemLanguageResultExecution timeMemory
382825SlavitaPo (COCI21_po)C++14
30 / 70
19 ms1132 KiB
#include <bits/stdc++.h> #define ve vector<int> #define pb push_back #define mp make_pair #define fi first #define se second #define pi pair<int,int> #define all(v) v.begin(),v.end() #define si(v) (int)v.size() #define en '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; const int N = 1e5 + 228; const int big = 1e9; int n, n2, a[N], b[N]; int main(){ iostream::sync_with_stdio(false); cin.tie(0); ios_base::sync_with_stdio(false); cout.tie(0); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); cin >> n; n2 = 0; b[0] = -9999999; for (int i = 1; i <= n; i++) {cin >> b[i]; if (b[i] != b[i - 1]) {n2++; a[n2] = b[i];}} int kol = 0, kol2 = 0; a[0] = 0; for (int i = 1; i <= n2; i++){ if (a[i] < a[i - 1] && a[i] < a[i + 1]) {i++; kol += 2; continue;} if (a[i] < a[i - 1]) kol++; } for (int i = 0; i <= n2; i++){ if (a[i] > a[i + 1]) kol2++; } cout << max(kol, kol2); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...