QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#368007#3918. Permutations againKLPP#WA 0ms3596kbC++20886b2024-03-26 18:17:442024-03-26 18:17:45

Judging History

This is the latest submission verdict.

  • [2024-03-26 18:17:45]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3596kb
  • [2024-03-26 18:17:44]
  • Submitted

answer

#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 long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
bool in[2000000];
void solve(){
	int n;
	cin>>n;
	vector<pair<int,int> >V(n);
	rep(i,0,n){
		cin>>V[i].first;
		V[i].second=i;
	}
	rep(i,0,n)in[i]=false;
	sort(V.begin(),V.end());
	int ans=0;
	int imb=0;
	trav(a,V){
		int x=a.second;
		in[x]=true;
		if(x>0 && in[x-1]){
			imb++;
		}
		if(x<n-1 && in[x+1]){
			imb++;
		}
		imb--;
		if(imb==-1){
			ans++;
		}
	}
	cout<<ans<<"\n";
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int tt=1;
	//cin>>tt;
	while(tt--){
		solve();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3564kb

input:

3
3 1 2

output:

3

result:

ok answer is '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1
1

output:

1

result:

ok answer is '1'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3544kb

input:

2
2 2

output:

2

result:

wrong answer expected '0', found '2'