답안 #359047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359047 2021-01-26T09:35:27 Z Ahmad_Hasan Money (IZhO17_money) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);
    int n;
    cin>>n;
    vector<int>v(n);

    for(int i=0;i<n;i++)
        cin>>v[i];
    int ans=0;
    unordered_multiset<int>ms;
    int f=0;
    int l=0;
    for(int i=0;i<n;i++){
        unordered_multiset<int>::iterator it1=ms.lower_bound(v[i]);
        unordered_multiset<int>::iterator it2=ms.upper_bound(v[i]);
        if((i+1<n)&&(v[i+1]<v[i]||(it2!=ms.end()&&*it2<v[i+1])||(it1!=ms.end()&&*it1>v[l]&&*it1<v[i+1]))){
            ans++;
            for(int j=l;j<=i;j++)
                ms.insert(v[j]);
            l=i+1;
        }

        if(i==n-1)
            ans++;
    }

    cout<<ans<<'\n';



    return 0;
}
/**
7
2 4 6 1 3 5 7
6
3 6 4 5 1 2
*/

Compilation message

money.cpp: In function 'int main()':
money.cpp:18:50: error: 'class std::unordered_multiset<int>' has no member named 'lower_bound'
   18 |         unordered_multiset<int>::iterator it1=ms.lower_bound(v[i]);
      |                                                  ^~~~~~~~~~~
money.cpp:19:50: error: 'class std::unordered_multiset<int>' has no member named 'upper_bound'
   19 |         unordered_multiset<int>::iterator it2=ms.upper_bound(v[i]);
      |                                                  ^~~~~~~~~~~
money.cpp:15:9: warning: unused variable 'f' [-Wunused-variable]
   15 |     int f=0;
      |         ^