답안 #1103540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103540 2024-10-21T08:02:32 Z stdfloat Money (IZhO17_money) C++17
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define ofk order_of_key

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto &i : a) {
		cin >> i; i--;
	}

	vector<int> ps(n);
	for (int i = 0; i < n; i++)
		ps[a[i]] = i;

	int cnt = 0;
	indexed_set s;
	vector<bool> vis(n);
	for (int i = 0; i < n; i++) {
		if (vis[ps[i]]) continue;
		cnt++;

		vector<int> v;
		for (int j = ps[i]; j < n && (j == ps[i] || a[j - 1] < a[j]) && !vis[j] && s.ofk(i) == s.ofk(a[j]); j++) {
			vis[j] = true;
			v.push_back(a[j]);
			if (s.find(a[j]) != s.end()) s.erase(a[j]);
		}

		for (auto j : v)
			s.insert(j);
	}

	cout << cnt;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -