ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201201 | #3483. deque | pipibob | 100 | 44ms | 1980kb | C++ | 953b | 2024-01-21 10:25:28 | 2024-01-21 12:06:24 |
answer
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
int read()
{
int x = 0, f = 1;
char ch = getchar();
while(ch < '0' || ch > '9')
{
if(ch == '-')
f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9')
{
x = (x << 3) + (x << 1) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
queue <int> a;
deque <int> q;
int n, x;
int main()
{
#ifndef ONLINE_JUDGE
// freopen("输入.in","r",stdin);
// freopen("输出.out","w",stdout);
#endif
n = read();
for(int i = 1 ; i <= n ; i++)
x = read(), a.push(x);
q.push_front(a.front()), a.pop();
while(a.size())
{
if(a.front() <= q.front())
q.push_front(a.front()), a.pop();
else
q.push_back(a.front()), a.pop();
}
for(int i = 0 ; i < n ; i++)
printf("%d%c", q[i], " \n"[i == n - 1]);
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
12 5 6 15 9 7 11 13 17 3 4 8 1 16 14 18 2 10
output:
1 3 5 6 15 9 7 11 13 17 4 8
result:
ok single line: '1 3 5 6 15 9 7 11 13 17 4 8'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
13 4 2 5 18 12 17 9 15 8 11 10 14 7 3 19 16 1 6
output:
2 4 5 18 12 17 9 15 8 11 10 14 7
result:
ok single line: '2 4 5 18 12 17 9 15 8 11 10 14 7'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
9 13 20 7 12 6 3 5 11 1 16 18 4 17 8 15 2 10 19 14
output:
1 3 6 7 13 20 12 5 11
result:
ok single line: '1 3 6 7 13 20 12 5 11'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
296 1001 1481 242 1288 558 1768 1030 411 1654 1174 560 1586 774 80 1917 1944 1979 1325 641 1834 1364...
output:
8 11 30 62 80 242 1001 1481 1288 558 1768 1030 411 1654 1174 560 1586 774 1917 1944 1979 1325 641 18...
result:
ok single line: '8 11 30 62 80 242 1001 1481 12...1106 1644 312 809 1575 646 1052'
Test #5:
score: 10
Accepted
time: 0ms
memory: 1208kb
input:
1856 1501 1453 363 450 1915 854 1597 1348 1916 1412 669 574 90 1974 1021 390 1284 1820 1388 1715 110...
output:
1 3 4 6 9 14 52 90 363 1453 1501 450 1915 854 1597 1348 1916 1412 669 574 1974 1021 390 1284 1820 13...
result:
ok single line: '1 3 4 6 9 14 52 90 363 1453 15...1 923 250 1945 1646 380 602 365'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
965 1911 248 1658 1241 991 1792 596 1123 1829 1709 1328 1358 445 1637 934 1400 1346 1571 995 1599 85...
output:
4 5 17 81 131 248 1911 1658 1241 991 1792 596 1123 1829 1709 1328 1358 445 1637 934 1400 1346 1571 9...
result:
ok single line: '4 5 17 81 131 248 1911 1658 12...998 1621 400 1887 20 46 328 110'
Test #7:
score: 10
Accepted
time: 0ms
memory: 1192kb
input:
253 1920 266 609 217 1653 64 1477 664 1915 1010 368 905 1337 1516 675 842 729 1141 202 555 1487 1468...
output:
8 52 64 217 266 1920 609 1653 1477 664 1915 1010 368 905 1337 1516 675 842 729 1141 202 555 1487 146...
result:
ok single line: '8 52 64 217 266 1920 609 1653 ... 993 197 716 273 1369 1569 1055'
Test #8:
score: 10
Accepted
time: 0ms
memory: 1188kb
input:
565 995 1768 950 1008 1825 1042 590 1482 1877 1253 805 750 369 629 1068 1916 230 1609 171 771 1537 1...
output:
6 15 18 19 125 171 230 369 590 950 995 1768 1008 1825 1042 1482 1877 1253 805 750 629 1068 1916 1609...
result:
ok single line: '6 15 18 19 125 171 230 369 590...8 233 1581 75 786 640 1094 1431'
Test #9:
score: 10
Accepted
time: 15ms
memory: 1772kb
input:
144742 177209 172172 84814 193683 199225 153842 187959 198438 153656 173678 198099 150049 153033 187...
output:
1 3 6 7 9 22 53 78 111 513 708 1479 62171 84814 172172 177209 193683 199225 153842 187959 198438 153...
result:
ok single line: '1 3 6 7 9 22 53 78 111 513 708...6007 100052 138169 99526 125689'
Test #10:
score: 10
Accepted
time: 29ms
memory: 1980kb
input:
184358 197379 186373 185190 178020 191800 193913 142834 196312 193864 184884 134703 187031 151062 12...
output:
1 6 7 19 53 56 81 311 585 14869 18003 19260 63790 74142 79363 125499 134703 142834 178020 185190 186...
result:
ok single line: '1 6 7 19 53 56 81 311 585 1486...706 122936 128655 118259 179510'