답안 #169178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169178 2019-12-18T19:15:54 Z itgl Money (IZhO17_money) C++14
0 / 100
2 ms 424 KB
#include<bits/stdc++.h>
#define pb push_back

using namespace std;
int a[1000005];
multiset <int> ms;

int main(){
  int n;
  cin >> n;
  for(int i=1;i<=n;i++) cin >> a[i];
  a[n+1]=-1;
  int pos;
  for(int i=1;i<=n;i++){
    if(a[i+1]>a[i]) ms.insert(a[i]);
    else{
      pos=i+1;
      ms.insert(a[i]);
      break;
    }
  }
  ms.insert(1e7+7);
  int ans=1;
  a[pos-1]=0;
  int lim=-1;
  for(int i=pos;i<=n;i++){
    if(a[i]<lim&&a[i-1]<=a[i]){
      ms.insert(a[i]);
    }else{
      ans++;
      lim=*ms.upper_bound(a[i]);
      //cout << lim << endl;
    }
  }
  cout << ans << '\n';
  return 0;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:13:7: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int pos;
       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 424 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -