답안 #910414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910414 2024-01-18T04:55:58 Z vjudge1 Money (IZhO17_money) C++17
0 / 100
1 ms 4444 KB
/*#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll n,m,k,cnt;
ll a[1000010];
ll mp[1000010];
ll tek[1000010];
void anomalous_solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
    	mp[a[i]]=i;
	}
	ll ans=0;
	mp[0]=100000000;
	for(int i=1;i<=n;i++)
	{
		//cout<<i<<" ";
		if(mp[i]-1==mp[i-1])
		{
			//cout<<ans<<"!\n";
			tek[i-1]=1;
			continue;
		}
		else
		{
			//cout<<a[mp[i]-1]<<" "<<mp[a[mp[i]-1]]+1<<" "<<tek[a[mp[i]-1]]<<"___";
			if(a[mp[i]-1]<i && mp[a[mp[i]-1]]+1==mp[i] && tek[a[mp[i]-1]]==0)
			{
				//cout<<ans<<"?\n";
				for(int j=a[mp[i]-1];j<i;j++)
				{
					tek[j]=1;
				}
				continue;
			}
			ans++;//cout<<ans<<"|\n";
		}
	}
	cout<<ans;
}
int main()
{
	//	freopen("INPUT.txt","r",stdin);
	//  freopen("OUTPUT.txt","w",stdout);

	ios_base::sync_with_stdio();
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
	//cin>>test;
    for(int pos=1;pos<=test;pos++)
    	anomalous_solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Incorrect 1 ms 4444 KB Output isn't correct
5 Halted 0 ms 0 KB -