답안 #985843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985843 2024-05-19T05:34:21 Z irmuun Money (IZhO17_money) C++17
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    int a[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int r=n;
    vector<int>v={0,(int)2e9};
    int ans=1;//n
    for(int i=n-1;i>=1;i--){
        if(a[i]>a[i+1]){
            ans++;
            r=i;
        }
        else{
            bool can=false;
            for(int j=0;j<v.size()-1;j++){
                if(v[j]<=a[i]&&a[r]<=v[j+1]){
                    can=true;
                }
            }
            if(!can){
                for(int j=i+1;j<=r;j++){
                    v.pb(a[j]);
                }
                sort(all(v));
                ans++;
                r=i;
            }
        }
    }
    cout<<ans;
}

Compilation message

money.cpp: In function 'int main()':
money.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for(int j=0;j<v.size()-1;j++){
      |                         ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -