Submission #643020

# Submission time Handle Problem Language Result Execution time Memory
643020 2022-09-21T04:36:57 Z ddy888 Baloni (COCI15_baloni) C++17
40 / 100
11 ms 6064 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops")
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
#define pb push_back
#define fi first
#define si second
#define ar array
typedef pair<int,int> pi;
typedef tuple<int,int,int> ti;  
template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
template<class key, class value = null_type, class cmp = less<key> >
using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 100010;

int n;
int arr[MAXN], f[MAXN];
set<int> pos[MAXN];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin.exceptions(ios::badbit | ios::failbit);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    for (int i = n; i >= 1; --i) {
        int p = arr[i]-1;
        if ((int)pos[p].size()) {
            f[*pos[p].begin()] = 1;
            pos[p].erase(*pos[p].begin());
        }
        pos[arr[i]].insert(i);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans += (f[i]==0);
    cout << ans;
    return 0;
}   
# Verdict Execution time Memory Grader output
1 Correct 3 ms 5076 KB Output is correct
2 Correct 3 ms 5076 KB Output is correct
3 Correct 3 ms 5076 KB Output is correct
4 Correct 3 ms 5168 KB Output is correct
5 Incorrect 11 ms 6008 KB Output isn't correct
6 Incorrect 9 ms 5972 KB Output isn't correct
7 Incorrect 8 ms 5972 KB Output isn't correct
8 Incorrect 9 ms 5972 KB Output isn't correct
9 Incorrect 9 ms 5972 KB Output isn't correct
10 Incorrect 9 ms 6064 KB Output isn't correct