답안 #585710

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585710 2022-06-29T08:55:56 Z 3omar_ahmed Baloni (COCI15_baloni) C++17
100 / 100
226 ms 7508 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std ;
using namespace __gnu_pbds;

#define int long long int
#define ordered_set tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>
#define CEIL(p1, p2) (p1+p2-1)/p2
#define all(a) a.begin() , a.end()
#define alr(a) a.rbegin() , a.rend()
#define FreI(pr1) freopen(pr1, "r", stdin);
#define FreO(pr1) freopen(pr1, "w", stdout);
int32_t main(){
    ios_base::sync_with_stdio(0), cin.tie(0),cout.tie(0);

    int n ;
    cin >> n;
    vector < int > a(n);
    for( auto &i : a ) cin >> i;
    int ans = 0 ;
    reverse(all(a));
    map < int , int > mp ;
    for( int i = 0 ; i < n ; i++ ){
        ( mp[a[i] - 1] ? mp[a[i] - 1]-- : ans++ );
        mp[a[i]]++;
    }
    cout << ans;
    return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 205 ms 6916 KB Output is correct
6 Correct 226 ms 7508 KB Output is correct
7 Correct 165 ms 6348 KB Output is correct
8 Correct 196 ms 6292 KB Output is correct
9 Correct 192 ms 6592 KB Output is correct
10 Correct 175 ms 6848 KB Output is correct