답안 #92813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92813 2019-01-05T06:21:40 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;
}
bool flag = 0, flag1 = 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++;
}
if (i > n) break;
if (a[i]>= minn){
    while (a[i] <= maxx and a[i] <= a[i+1]){
        i++;
    }
    if (a[i] <= maxx)i++;
    cnt++;
}
if (i > n) break;
if (a[i] < minn){
    int t = a[i];
    while (a[i] <= minn and a[i] <= a[i+1]){
        i++;
    }
    minn = t;
   if (a[i] <= minn) i++;

    cnt++;
}
}

cout << cnt ;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:34:6: warning: unused variable 'flag' [-Wunused-variable]
 bool flag = 0, flag1 = 0;
      ^~~~
money.cpp:34:16: warning: unused variable 'flag1' [-Wunused-variable]
 bool flag = 0, flag1 = 0;
                ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 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 2 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 2 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 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -