QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368007 | #3918. Permutations again | KLPP# | WA | 0ms | 3596kb | C++20 | 886b | 2024-03-26 18:17:44 | 2024-03-26 18:17:45 |
Judging History
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'