QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#141584#2143. Railroad sortingAs3b_team_f_masr#TL 19ms5640kbC++141.0kb2023-08-17 16:58:552023-08-17 16:58:57

Judging History

你现在查看的是最新测评结果

  • [2023-08-17 16:58:57]
  • 评测
  • 测评结果:TL
  • 用时:19ms
  • 内存:5640kb
  • [2023-08-17 16:58:55]
  • 提交

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, 0, 0, 1, -1, 1};
int dj[] = {0, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 1e9 + 7;
const int N = 5e5 + 5, M = 30005;


int t, n, m, ans, a[N], pos[N];

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n + 1; i++) pos[i] = -1;
    stack<int> s[2];
    int id = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s[0].push(a[i]);
        pos[a[i]] = 0;
        cout << 1 << endl;
        while (~pos[id]) {
            while (s[pos[id]].top() != id) {
                s[!pos[id]].push(s[pos[id]].top());
                pos[s[pos[id]].top()] = !pos[id];
                s[pos[id]].pop();
                cout << pos[id] + 1 << !pos[id] + 1 << endl;
            }
            s[pos[id]].pop();
            cout << -(pos[id] + 1) << endl;
            id++;
        }
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

input:

5
3 1 5 2 4

output:

1
1
-1
1
1
-1
12
-1
1
-1
-2

result:

ok 11 steps

Test #2:

score: 0
Accepted
time: 1ms
memory: 5548kb

input:

1
1

output:

1
-1

result:

ok 2 steps

Test #3:

score: 0
Accepted
time: 2ms
memory: 5572kb

input:

2
1 2

output:

1
-1
1
-1

result:

ok 4 steps

Test #4:

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

input:

2
2 1

output:

1
1
-1
-1

result:

ok 4 steps

Test #5:

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

input:

3
1 2 3

output:

1
-1
1
-1
1
-1

result:

ok 6 steps

Test #6:

score: 0
Accepted
time: 1ms
memory: 5508kb

input:

3
1 3 2

output:

1
-1
1
1
-1
-1

result:

ok 6 steps

Test #7:

score: 0
Accepted
time: 1ms
memory: 5544kb

input:

3
2 1 3

output:

1
1
-1
-1
1
-1

result:

ok 6 steps

Test #8:

score: 0
Accepted
time: 1ms
memory: 5508kb

input:

3
2 3 1

output:

1
1
1
-1
12
-1
-2

result:

ok 7 steps

Test #9:

score: 0
Accepted
time: 1ms
memory: 5504kb

input:

3
3 1 2

output:

1
1
-1
1
-1
-1

result:

ok 6 steps

Test #10:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

3
3 2 1

output:

1
1
1
-1
-1
-1

result:

ok 6 steps

Test #11:

score: 0
Accepted
time: 2ms
memory: 5628kb

input:

10
1 2 3 4 5 6 7 8 9 10

output:

1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1

result:

ok 20 steps

Test #12:

score: 0
Accepted
time: 2ms
memory: 5504kb

input:

10
10 9 8 7 6 5 4 3 2 1

output:

1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

result:

ok 20 steps

Test #13:

score: 0
Accepted
time: 2ms
memory: 5632kb

input:

10
1 10 2 9 3 8 4 7 5 6

output:

1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
-1
-1
-1
-1
-1

result:

ok 20 steps

Test #14:

score: 0
Accepted
time: 1ms
memory: 5568kb

input:

10
2 4 6 8 10 9 7 5 3 1

output:

1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
-1
21
21
21
21
21
21
21
-2
12
12
12
12
12
12
-1
21
21
21
21
21
-2
12
12
12
12
-1
21
21
21
-2
12
12
-1
21
-2
-1

result:

ok 56 steps

Test #15:

score: 0
Accepted
time: 2ms
memory: 5516kb

input:

10
3 9 8 5 7 4 1 2 10 6

output:

1
1
1
1
1
1
1
-1
1
-1
12
12
12
12
12
-1
21
21
21
21
-2
12
-1
1
1
-1
-2
12
-1
-1
-2

result:

ok 31 steps

Test #16:

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

input:

10
7 8 2 5 9 6 1 10 4 3

output:

1
1
1
1
1
1
1
-1
12
12
12
-1
1
1
1
-1
-1
-2
21
-2
12
12
12
-1
-2
21
-2
-1

result:

ok 28 steps

Test #17:

score: 0
Accepted
time: 2ms
memory: 5512kb

input:

10
3 7 5 8 10 4 6 2 9 1

output:

1
1
1
1
1
1
1
1
1
1
-1
12
-1
12
12
12
12
12
12
-1
21
21
21
21
-2
12
12
-1
21
21
-2
12
12
-1
-2
21
-2
-1

result:

ok 38 steps

Test #18:

score: 0
Accepted
time: 2ms
memory: 5572kb

input:

73
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

output:

1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
...

result:

ok 146 steps

Test #19:

score: 0
Accepted
time: 2ms
memory: 5504kb

input:

73
73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 146 steps

Test #20:

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

input:

73
1 73 2 72 3 71 4 70 5 69 6 68 7 67 8 66 9 65 10 64 11 63 12 62 13 61 14 60 15 59 16 58 17 57 18 56 19 55 20 54 21 53 22 52 23 51 24 50 25 49 26 48 27 47 28 46 29 45 30 44 31 43 32 42 33 41 34 40 35 39 36 38 37

output:

1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok 146 steps

Test #21:

score: 0
Accepted
time: 10ms
memory: 5568kb

input:

73
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 72 70 68 66 64 62 60 58 56 54 52 50 48 46 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2

output:

1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
1...

result:

ok 2631 steps

Test #22:

score: 0
Accepted
time: 9ms
memory: 5564kb

input:

73
24 1 38 69 53 21 8 19 18 31 4 70 67 35 7 15 47 33 16 34 39 6 48 57 56 11 2 51 41 40 66 10 25 73 23 3 45 30 28 36 37 5 60 43 71 14 59 58 55 72 65 26 62 44 12 68 63 61 20 32 9 17 54 13 22 50 46 49 29 27 52 64 42

output:

1
1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
-1
1
1
1
1
1
1
-1
21
21
21
21
21
21
21
21
21
21
-2
12
12
12
12
12
12
-1
12
12
12
12
12
12
12
12
12
12
12
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
2...

result:

ok 701 steps

Test #23:

score: 0
Accepted
time: 4ms
memory: 5508kb

input:

73
52 58 60 43 68 51 56 22 23 47 10 16 62 9 18 38 1 72 13 44 32 63 24 46 48 12 2 3 45 36 67 17 19 50 31 7 42 66 41 5 27 6 55 59 35 49 14 65 21 8 39 70 33 25 53 26 57 20 34 28 54 11 64 69 40 4 71 37 30 29 73 61 15

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
1
1
1
1
1
1
1
1
-1
1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
-1
21
-2
12
12
12
12
-1
21
21
21
21
21
21
21
21
21
21
21
-2
12
12
12
12
12
12
12
...

result:

ok 778 steps

Test #24:

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

input:

73
45 40 28 67 3 46 55 57 52 2 31 30 62 66 33 47 61 58 21 17 34 41 69 63 32 65 51 25 18 15 39 22 16 56 71 70 14 73 9 38 27 60 19 5 29 36 20 42 48 68 23 59 4 44 72 35 50 53 49 1 7 37 13 12 26 10 6 11 24 43 8 64 54

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
-1
12
12
12
12
-1
21
21
21
21
...

result:

ok 730 steps

Test #25:

score: 0
Accepted
time: 3ms
memory: 5576kb

input:

239
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

output:

1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
...

result:

ok 478 steps

Test #26:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

239
239 238 237 236 235 234 233 232 231 230 229 228 227 226 225 224 223 222 221 220 219 218 217 216 215 214 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 197 196 195 194 193 192 191 190 189 188 187 186 185 184 183 182 181 180 179 178 177 176 175 174 173 172 171 170 169 168 167 166 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 478 steps

Test #27:

score: 0
Accepted
time: 6ms
memory: 5636kb

input:

239
1 239 2 238 3 237 4 236 5 235 6 234 7 233 8 232 9 231 10 230 11 229 12 228 13 227 14 226 15 225 16 224 17 223 18 222 19 221 20 220 21 219 22 218 23 217 24 216 25 215 26 214 27 213 28 212 29 211 30 210 31 209 32 208 33 207 34 206 35 205 36 204 37 203 38 202 39 201 40 200 41 199 42 198 43 197 44 1...

output:

1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1...

result:

ok 478 steps

Test #28:

score: 0
Accepted
time: 19ms
memory: 5548kb

input:

239
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 169 171 173 175...

output:

1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 28444 steps

Test #29:

score: 0
Accepted
time: 6ms
memory: 5548kb

input:

239
64 85 148 52 182 174 96 100 213 162 2 71 60 201 9 99 184 118 228 49 50 216 208 8 210 38 183 190 204 234 53 21 45 219 124 134 157 180 16 116 101 105 93 176 41 140 221 5 55 48 145 161 164 169 185 70 230 136 165 72 178 236 83 127 166 120 104 160 112 97 163 4 33 87 47 13 232 200 159 154 10 177 212 1...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12...

result:

ok 9402 steps

Test #30:

score: 0
Accepted
time: 12ms
memory: 5520kb

input:

239
224 84 121 89 222 105 60 2 122 52 142 221 116 205 88 86 21 34 42 55 158 75 37 171 218 18 19 64 235 124 47 30 10 44 95 225 190 175 162 123 188 220 97 1 149 229 143 172 202 185 46 22 59 56 206 167 27 174 66 41 92 17 39 20 189 114 106 57 112 141 191 208 210 102 51 215 170 74 165 198 16 72 133 233 2...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
12
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

result:

ok 10144 steps

Test #31:

score: 0
Accepted
time: 2ms
memory: 5512kb

input:

239
26 206 53 21 211 223 235 85 205 180 77 22 82 126 81 116 1 194 183 109 63 49 28 86 31 12 13 220 200 76 155 130 99 178 163 237 2 50 150 236 189 56 39 95 9 11 125 166 231 185 146 221 78 225 48 212 160 29 209 135 66 215 175 190 133 219 64 44 153 57 137 121 10 88 91 36 218 43 35 128 87 164 174 234 41...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 9145 steps

Test #32:

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

input:

1000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

output:

1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
1
-1
...

result:

ok 2000 steps

Test #33:

score: 0
Accepted
time: 2ms
memory: 5588kb

input:

1000
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 92...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 steps

Test #34:

score: 0
Accepted
time: 2ms
memory: 5512kb

input:

1000
1 1000 2 999 3 998 4 997 5 996 6 995 7 994 8 993 9 992 10 991 11 990 12 989 13 988 14 987 15 986 16 985 17 984 18 983 19 982 20 981 21 980 22 979 23 978 24 977 25 976 26 975 27 974 28 973 29 972 30 971 31 970 32 969 33 968 34 967 35 966 36 965 37 964 38 963 39 962 40 961 41 960 42 959 43 958 44...

output:

1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1
1
-1
1...

result:

ok 2000 steps

Test #35:

score: -100
Time Limit Exceeded

input:

1000
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 162 164 166 168 170 172 174 ...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result: