Skip to content

Commit 693f07b

Browse files
committed
Permutation Minimization by Deque
1 parent f046236 commit 693f07b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

1579E1.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(){
5+
int t;
6+
cin>>t;
7+
8+
int n;
9+
while(t--){
10+
deque <int> deqs;
11+
cin>>n;
12+
int x;
13+
for(int i = 0; i < n;i++){
14+
cin>>x;
15+
if(x > deqs.front()){
16+
deqs.push_back(x);
17+
continue;
18+
}
19+
deqs.push_front(x);
20+
}
21+
for(int i = 0; i < n; i++){
22+
cout<<deqs.at(i)<<" ";
23+
}
24+
cout<<endl;
25+
}
26+
}

0 commit comments

Comments
 (0)