Submission #710129

# Submission time Handle Problem Language Result Execution time Memory
710129 2023-03-15T05:01:45 Z arcane Money (IZhO17_money) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int ans = 0, n, x, prevx = -1; cin >> n;
	int arr[n]; for (int i = 0; i < n; i++) cin >> arr[i];
	multiset <int> ms;
	set <int> s;
	bool flag = false;
	for (int i = 0; i < n; i++){
		x = arr[i];
		ms.insert(arr[i]);
		s.insert(arr[i]);
		if (!i){
			ans += 1;
			flag = true;
		}
		else if (flag){
			if (prevx > x){
				ans += 1;
				flag = true;
			} 
			else if (prevx < x){
				auto it = s.find(prevx);
				it++;
				if (it != s.end() and *it <= x){
					flag = false;
				}
				else ans += 1, flag = true;
			}
		}
		else{
			if (prevx > x){
				ans += 1;
				flag = true;
			}
			else if (prevx < x){
				auto it = s.find(prevx);
				it++;
				if (it != s.end() and x <= *it and ms.count(prevx) == 1){
					//cerr << prevx << ' ' << *it << ' ' << x << '\n';
					flag = false;
				}
				else ans += 1, flag = true;
			}
		}
		//cerr << ans << '\n';
		//cerr << ans << ' ' << *prev << ' ' << *cur << '\n';
		prevx = x;
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -