답안 #92816

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92816 2019-01-05T06:36:24 Z I_am_muslim Money (IZhO17_money) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define in freopen("input.txt", "r" ,stdin)
#define out freopen("output.txt", "w" , stdout)
#define ll long long
#define inf 200005
#define fr first
#define  sc second
#define pb push_back
#define p_b pop_back
#define mp make_pair
using namespace std;
int n;
int a[1000005];
int main (){
//in;out;
ios_base::sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}

int maxx = 0;
int minn = 1e6+10;
a[0] = 0;
minn = a[1];
int ind = 1;
for (int i = 1; i <=n; i++){
    if (a[i] >= a[i-1]) {
       ind = i;
        maxx = a[i];
    }
    else break;
}
minn = a[1];
if (ind == n){cout << 0;return 0;}
int cnt = 1;
for (int i = ind+1 ; i <= n; i++) {
if (a[i] >= maxx){
while (a[i] >= maxx){
    maxx = a[i];
    i++;
}
cnt++;
continue;
}
if (a[i]>= minn){
    while (a[i] <= maxx and a[i] <= a[i+1]){
        i++;
    }
    cnt++;
    continue;
}
if (a[i] < minn){
    int t = a[i];
    while (a[i] <= minn and a[i] <= a[i+1]){
        i++;
    }
    minn = t;
    cnt++;
}
}

cout << cnt ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 1 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -