답안 #485814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485814 2021-11-09T12:18:40 Z asandikci Baloni (COCI15_baloni) C++17
100 / 100
740 ms 7236 KB
/*
Aliberk Sandıkçı
9 November 2021
Current Rank: Newbie: 1033 (max.1188)
Current Grade: 10th in Izmir Science High School
Current Competitive Programming Achievements:
    * Turkey National Informatics Olympiad 2021 - 1st Stage: 27th place
    * Turkey Izmir Science Olympiad (Informatics Branch) 2021 - 1st Stage: 4th place
More About Me: ***there will be LinkedIN link soon*** 
*/
 
#include "bits/stdc++.h"
#define pb push_back
#define lwb lower_bound
#define upb upper_bound
#define fi first
#define se second
#define debu cout << "*debug*\n"
#define debug(x) cout << "debug " << x <<"\n"
#define int long long
constexpr int modn = 1e9+7;     // 998244353
constexpr int maxn = 1e6+5; 
constexpr int INF = 1e9+5;  
using namespace std;


void solve(){
    int n;
    cin >> n;
    int arr[n+5];
    for(int i=0;i<n;i++){
        cin >> arr[i];
    }
    vector<int> vec;    
    for(int i=0;i<n;i++){
        vector<int>::iterator ix=vec.begin();
        int ins=0;
        for(auto it : vec){
            if(arr[i]==it-1){
                if(ins<vec.size())vec.erase(ix);
                break;
            }
            ins++;
            ix++;
        }
        vec.pb(arr[i]);
        /*for(auto it: vec){
            cout << it << " ";
        }cout << "\n";*/
    }
    cout << vec.size();
    


}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); 
    //freopen("","r",stdin);
    //freopen("","w",stdout);   
    
    int T=1;
    //cin >> T; 
    while(T--){
        solve();    
    }   
    return 0;
}

Compilation message

baloni.cpp: In function 'void solve()':
baloni.cpp:40:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |                 if(ins<vec.size())vec.erase(ix);
      |                    ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 379 ms 6624 KB Output is correct
6 Correct 740 ms 7236 KB Output is correct
7 Correct 636 ms 6080 KB Output is correct
8 Correct 605 ms 6084 KB Output is correct
9 Correct 506 ms 6292 KB Output is correct
10 Correct 628 ms 6548 KB Output is correct