Submission #710304

# Submission time Handle Problem Language Result Execution time Memory
710304 2023-03-15T06:53:50 Z ld_minh4354 Money (IZhO17_money) C++17
0 / 100
7 ms 15960 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int long long
#define fi first
#define se second
#define pb push_back
#define debug(x) cout<<#x<<": "<<x<<"\n"



signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//	freopen("input.000","r",stdin);
//	freopen("output.000","w",stdout);
//	srand((unsigned)time(NULL));
//	rand()
	
	int n,a[1000005],b[1000005],i,ans,first_num;
	map<int,int> m;
	
	
	cin>>n;
	for (i=1;i<n+1;i++) cin>>a[i];
	
	for (i=1;i<n+1;i++) b[i]=a[i];
	sort(b+1,b+n+1);
	for (i=1;i<n+1;i++) if (m.count(b[i])==0) m[b[i]]=1;else m[b[i]]+=1;
	
	ans=1;first_num=a[n];m[a[n]]--;
	for (i=n-1;i>0;i--)
	{
		if (a[i]>a[i+1] or (a[i]<a[i+1] and m[a[i+1]]!=0 and a[i+1]!=first_num))
		{
			ans++;
			first_num=a[i];
		}
		m[a[i]]--;
	}
	
	cout<<ans;
}

# Verdict Execution time Memory Grader output
1 Correct 6 ms 15956 KB Output is correct
2 Incorrect 7 ms 15960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15956 KB Output is correct
2 Incorrect 7 ms 15960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15956 KB Output is correct
2 Incorrect 7 ms 15960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15956 KB Output is correct
2 Incorrect 7 ms 15960 KB Output isn't correct
3 Halted 0 ms 0 KB -