# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
382825 | Slavita | Po (COCI21_po) | C++14 | 19 ms | 1132 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |