/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 536.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 2ms 532.0 KiB
#5 Accepted 3ms 532.0 KiB
#6 Accepted 3ms 532.0 KiB
#7 Accepted 4ms 532.0 KiB
#8 Accepted 4ms 532.0 KiB
#9 Accepted 4ms 532.0 KiB
#10 Accepted 4ms 532.0 KiB
#11 Accepted 4ms 532.0 KiB
#12 Accepted 4ms 532.0 KiB
#13 Accepted 4ms 324.0 KiB
#14 Wrong Answer 4ms 532.0 KiB

Code

#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void shelby() {
    int n;
    cin >> n;
    vector<int> v(n);
    cinv(v)
    auto calc = [&]()-> vector<int> {
        vector<int> ret(n);
        ordered_set<int> o;
        for (int i = 0; i < n; ++i) {
            int x = o.order_of_key(v[i] + 1);
            if (x >= abs(v[i])) ret[i] = 1;
            o.insert(v[i]);
        }
        return ret;
    };
    vector<int> ans = calc();
    for (auto &it: v) it *= -1;
    reverse(v.begin(), v.end());
    debug(v);
    vector<int> ans2 = calc();
    reverse(ans2.begin(), ans2.end());
    int cnt = 0;
    for (int i = 0; i < n; ++i) cnt += (ans[i] | ans2[i]);
    cout << cnt << '\n';
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case " << _ << ": ";
        shelby();
    }
}

Information

Submit By
Type
Submission
Problem
P1184 The Curious Kid and the Number Game
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-08 16:32:18
Judged At
2025-04-08 16:32:18
Judged By
Score
12
Total Time
4ms
Peak Memory
536.0 KiB