/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 344.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Accepted 4ms 536.0 KiB
#4 Accepted 4ms 352.0 KiB
#5 Accepted 4ms 532.0 KiB
#6 Accepted 4ms 532.0 KiB
#7 Accepted 5ms 568.0 KiB
#8 Accepted 4ms 576.0 KiB
#9 Wrong Answer 4ms 532.0 KiB

Code

#include<bits/stdc++.h>
#define ll                  long long
#define nl                  '\n'
#define F                   first
#define S                   second
#define all(a)              (a.begin()),(a.end())
#define UNIQUE(X)           (X).erase(unique(all(X)),(X).end())
#define SORT_UNIQUE(c)      (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define ms(a,b)             memset(a, b, sizeof(a))
#define Input               freopen("in.txt","r",stdin)
#define Output              freopen("out.txt","w",stdout)
#define MOD                 1000000007
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T> using orderset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 5;
ll a[N], b[N];

void Solve(int t)
{
	ll n;
	cin >> n;
	orderset<ll> s;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (s.size() >= a[i]) {
			ll x = s.order_of_key(a[i] - 1);
			if (x <= a[i])
				b[i]++;
		}
		s.insert(a[i]);
	}
	s.clear();
	for (int i = n; i >= 1; i--)
	{
		if (s.size() >= a[i]) {
			ll j = s.size() - a[i];
			ll x = s.order_of_key(j);
			if (x >= a[i])
				b[i]++;
		}
		s.insert(a[i]);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		// cout << b[i] << ' ';
		if (b[i] > 0)
			ans++;
	}
	// cout << endl;
	cout << ans << endl;

}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t, T = 1;
	// cin >> T;
	for (t = 1; t <= T; t++)
		Solve(t);
	return 0;
}

Information

Submit By
Type
Submission
Problem
P1184 The Curious Kid and the Number Game
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 15:55:08
Judged At
2025-04-06 15:55:08
Judged By
Score
7
Total Time
5ms
Peak Memory
576.0 KiB