QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#430069#4565. Rarest Insectsjames1BadCreeper#0 39ms4200kbC++171.7kb2024-06-03 13:30:252024-06-03 13:30:26

Judging History

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

  • [2024-06-03 13:30:26]
  • 评测
  • 测评结果:0
  • 用时:39ms
  • 内存:4200kb
  • [2024-06-03 13:30:25]
  • 提交

answer

#include "insects.h"
#include <bits/stdc++.h>
using namespace std; 
const int N = 2e3 + 5; 

// 最多问 3n 次询问
int n, m, k, id[N], always_no[N]; 
vector<int> arr; 
bool in[N]; 
mt19937 Rand(time(0)); 

void Move_inside(int x) { move_inside(id[x] - 1); }
void Move_outside(int x) { move_outside(id[x] - 1); }
bool check(int x) { // 最罕见的昆虫是否能 >= x
    int cnt = n; 
    for (int i = 1; i <= n; ++i) if (always_no[i] == 1) {
        Move_inside(i); in[i] = 1; 
        if (press_button() > x) {
            Move_outside(i), in[i] = 0, --cnt; 
            // if (cnt < k * x) {
                // for (int i : arr)
                    // if (in[i]) Move_outside(i), in[i] = 0; 
                // return 0; 
            // }
        }
    }
    if (cnt == k * x) {
        for (int i = 1; i <= n; ++i)
            if (in[i]) always_no[i] = 0; 
    }
    for (int i : arr)
        if (in[i]) Move_outside(i); 
    return cnt == k * x; 
}
int min_cardinality(int N) {
    n = N; 
    k = n; 
    for (int i = 1; i <= n; ++i) id[i] = i, always_no[i] = 0; 
    shuffle(id + 1, id + n + 1, Rand);  
    for (int i = 1; i <= n; ++i) {
        Move_inside(i); 
        if (press_button() > 1) Move_outside(i), --k, always_no[i] = 1; 
    }

    // 最罕见的出现次数是 1,当且仅当什么时候?
    int L = 0, R = n / k + 1; // [2, n / k]

    while (L + 1 != R) {
        int mid = L + R >> 1; 
        if (check(mid)) L = mid; 
        else R = mid; 
    }
    return L; 
}

// 我们可以知道的信息:

// n 次代价知道昆虫种类数 k
// n 次代价知道最常见的昆虫基数

// 那么最罕见的昆虫的基数至多是 n / k
// 直接扫,

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

6
1
1
1
2
2
2
2
2
2
2
2
3

output:

8
0 0
8
2
8
0 1
8
2
8
0 2
8
2
8
0 5
8
2
8
1 5
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
1 5
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 5
8
2
8
0 3
8
2
8
0 4
8
2
8
1 4
8
3 1

result:

ok 

Test #2:

score: 10
Accepted
time: 1ms
memory: 3960kb

input:

2
1
2
2
2

output:

8
0 0
8
2
8
0 1
8
2
8
1 1
8
0 1
8
2
8
1 1
8
0 1
8
2
8
3 2

result:

ok 

Test #3:

score: 10
Accepted
time: 1ms
memory: 3932kb

input:

2
1
1

output:

8
0 0
8
2
8
0 1
8
2
8
3 1

result:

ok 

Test #4:

score: 10
Accepted
time: 1ms
memory: 3888kb

input:

3
1
1
2
2

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
1 1
8
0 1
8
2
8
1 1
8
3 1

result:

ok 

Test #5:

score: 10
Accepted
time: 1ms
memory: 3956kb

input:

5
1
1
2
2
2
2
2
2
2
2
3

output:

8
0 0
8
2
8
0 2
8
2
8
0 1
8
2
8
1 1
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
0 1
8
2
8
1 1
8
0 4
8
2
8
1 4
8
0 3
8
2
8
1 3
8
0 1
8
2
8
0 4
8
2
8
0 3
8
2
8
1 3
8
3 2

result:

ok 

Test #6:

score: 10
Accepted
time: 1ms
memory: 3932kb

input:

8
1
1
1
2
2
2
2
2
2
2
2
2
2
2
3
3
3
2

output:

8
0 0
8
2
8
0 1
8
2
8
0 7
8
2
8
0 5
8
2
8
1 5
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 6
8
2
8
1 6
8
0 5
8
2
8
1 5
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 6
8
2
8
1 6
8
0 5
8
2
8
0 3
8
2
8
1 3
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 6
8
2
8
3 1

result:

ok 

Test #7:

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

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 142
8
2
8
0 60
8
2
8
1 60
8
0 45
8
2
8
1 45
8
0 143
8
2
8
1 143
8
0 184
8
2
8
1 184
8
0 82
8
2
8
1 82
8
0 109
8
2
8
1 109
8
0 117
8
2
8
1 117
8
0 49
8
2
8
1 49
8
0 38
8
2
8
1 38
8
0 190
8
2
8
1 190
8
0 13
8
2
8
1 13
8
0 40
8
2
8
1 40
8
0 79
8
2
8
1 79
8
0 3
8
2
8
1 3
8
0 18
8
2
8
1 18
8
0 6
8
2
...

result:

ok 

Test #8:

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

input:

200
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

output:

8
0 187
8
2
8
0 161
8
2
8
0 91
8
2
8
0 142
8
2
8
0 92
8
2
8
0 28
8
2
8
0 108
8
2
8
0 116
8
2
8
0 26
8
2
8
0 106
8
2
8
0 141
8
2
8
0 111
8
2
8
0 119
8
2
8
0 78
8
2
8
0 31
8
2
8
0 155
8
2
8
0 65
8
2
8
0 58
8
2
8
0 163
8
2
8
0 102
8
2
8
0 50
8
2
8
0 180
8
2
8
0 16
8
2
8
0 132
8
2
8
0 131
8
2
8
0 171
8
...

result:

ok 

Test #9:

score: 10
Accepted
time: 1ms
memory: 3880kb

input:

200
1
1
1
2
2
1
1
1
1
1
1
1
1
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 187
8
2
8
0 161
8
2
8
0 91
8
2
8
0 142
8
2
8
1 142
8
0 92
8
2
8
1 92
8
0 28
8
2
8
0 108
8
2
8
0 116
8
2
8
0 26
8
2
8
0 106
8
2
8
0 141
8
2
8
0 111
8
2
8
0 119
8
2
8
0 78
8
2
8
1 78
8
0 31
8
2
8
0 155
8
2
8
1 155
8
0 65
8
2
8
1 65
8
0 58
8
2
8
1 58
8
0 163
8
2
8
0 102
8
2
8
1 102
8
0 50
8
2
8
1 5...

result:

ok 

Test #10:

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

input:

198
1
1
1
1
1
2
1
2
1
1
2
1
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 187
8
2
8
0 161
8
2
8
0 91
8
2
8
0 142
8
2
8
0 92
8
2
8
0 28
8
2
8
1 28
8
0 108
8
2
8
0 116
8
2
8
1 116
8
0 26
8
2
8
0 106
8
2
8
0 141
8
2
8
1 141
8
0 111
8
2
8
0 119
8
2
8
0 78
8
2
8
1 78
8
0 31
8
2
8
1 31
8
0 155
8
2
8
0 65
8
2
8
1 65
8
0 58
8
2
8
1 58
8
0 163
8
2
8
1 163
8
0 102
8
2
8
1 102
8...

result:

ok 

Test #11:

score: 10
Accepted
time: 7ms
memory: 4180kb

input:

199
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 142
8
2
8
0 60
8
2
8
1 60
8
0 45
8
2
8
1 45
8
0 143
8
2
8
1 143
8
0 184
8
2
8
1 184
8
0 82
8
2
8
1 82
8
0 109
8
2
8
1 109
8
0 117
8
2
8
1 117
8
0 49
8
2
8
1 49
8
0 38
8
2
8
1 38
8
0 190
8
2
8
1 190
8
0 13
8
2
8
1 13
8
0 40
8
2
8
1 40
8
0 79
8
2
8
1 79
8
0 3
8
2
8
1 3
8
0 18
8
2
8
1 18
8
0 6
8
2
...

result:

ok 

Test #12:

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

input:

197
1
1
2
2
1
2
1
2
1
2
1
1
1
2
1
1
2
1
2
1
2
2
2
1
1
1
1
1
1
1
2
2
1
2
2
1
2
2
2
2
1
1
2
2
2
1
1
1
2
2
1
1
1
2
1
2
1
2
2
2
1
2
1
1
1
1
1
1
1
2
1
1
2
2
2
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
1
1
2
2
2
1
1
2
1
1
2
1
1
1
1
2
2
1
1
2
1
2
2
2
1
1
1
2
1
1
2
1
1
2
2
2
2
2
2
2
2
2
2
2
1
2
1
1
2
1
1
1
1
1
2
1
...

output:

8
0 183
8
2
8
0 104
8
2
8
0 27
8
2
8
1 27
8
0 68
8
2
8
1 68
8
0 66
8
2
8
0 67
8
2
8
1 67
8
0 117
8
2
8
0 81
8
2
8
1 81
8
0 159
8
2
8
0 15
8
2
8
1 15
8
0 10
8
2
8
0 24
8
2
8
0 82
8
2
8
0 2
8
2
8
1 2
8
0 22
8
2
8
0 19
8
2
8
0 136
8
2
8
1 136
8
0 106
8
2
8
0 17
8
2
8
1 17
8
0 185
8
2
8
0 138
8
2
8
1 13...

result:

ok 

Test #13:

score: 10
Accepted
time: 3ms
memory: 3852kb

input:

197
1
2
1
1
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 183
8
2
8
0 104
8
2
8
1 104
8
0 27
8
2
8
0 68
8
2
8
0 66
8
2
8
1 66
8
0 67
8
2
8
1 67
8
0 117
8
2
8
1 117
8
0 81
8
2
8
1 81
8
0 159
8
2
8
1 159
8
0 15
8
2
8
1 15
8
0 10
8
2
8
1 10
8
0 24
8
2
8
0 82
8
2
8
1 82
8
0 2
8
2
8
1 2
8
0 22
8
2
8
0 19
8
2
8
1 19
8
0 136
8
2
8
1 136
8
0 106
8
2
8
1 106
8
...

result:

ok 

Test #14:

score: 10
Accepted
time: 5ms
memory: 3888kb

input:

198
1
1
1
2
1
2
1
1
2
1
1
2
1
1
2
1
2
2
2
1
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 182
8
2
8
0 30
8
2
8
0 26
8
2
8
0 48
8
2
8
1 48
8
0 66
8
2
8
0 102
8
2
8
1 102
8
0 116
8
2
8
0 80
8
2
8
0 158
8
2
8
1 158
8
0 47
8
2
8
0 123
8
2
8
0 22
8
2
8
1 22
8
0 71
8
2
8
0 21
8
2
8
0 25
8
2
8
1 25
8
0 115
8
2
8
0 117
8
2
8
1 117
8
0 38
8
2
8
1 38
8
0 3
8
2
8
1 3
8
0 184
8
2
8
0 41
8
2
8
1 ...

result:

ok 

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

200
1
1
2
1
2
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 198
8
2
8
0 30
8
2
8
0 26
8
2
8
1 26
8
0 48
8
2
8
0 66
8
2
8
1 66
8
0 102
8
2
8
1 102
8
0 116
8
2
8
1 116
8
0 80
8
2
8
1 80
8
0 158
8
2
8
1 158
8
0 47
8
2
8
1 47
8
0 123
8
2
8
1 123
8
0 22
8
2
8
0 71
8
2
8
1 71
8
0 21
8
2
8
1 21
8
0 25
8
2
8
1 25
8
0 115
8
2
8
0 117
8
2
8
1 117
8
0 38
8
2
8
1 38...

result:

wrong answer Wrong answer.

Subtask #2:

score: 0
Wrong Answer

Test #24:

score: 15
Accepted
time: 17ms
memory: 3900kb

input:

1000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 750
8
2
8
0 293
8
2
8
1 293
8
0 249
8
2
8
1 249
8
0 792
8
2
8
1 792
8
0 66
8
2
8
1 66
8
0 531
8
2
8
1 531
8
0 352
8
2
8
1 352
8
0 471
8
2
8
1 471
8
0 232
8
2
8
1 232
8
0 47
8
2
8
1 47
8
0 857
8
2
8
1 857
8
0 916
8
2
8
1 916
8
0 280
8
2
8
1 280
8
0 21
8
2
8
1 21
8
0 642
8
2
8
1 642
8
0 752
8
2
8
...

result:

ok 

Test #25:

score: 15
Accepted
time: 0ms
memory: 3888kb

input:

1000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 750
8
2
8
0 293
8
2
8
0 249
8
2
8
0 792
8
2
8
0 66
8
2
8
0 531
8
2
8
0 352
8
2
8
0 471
8
2
8
0 232
8
2
8
0 47
8
2
8
0 857
8
2
8
0 916
8
2
8
0 280
8
2
8
0 21
8
2
8
0 642
8
2
8
0 752
8
2
8
0 913
8
2
8
0 38
8
2
8
0 543
8
2
8
0 737
8
2
8
0 689
8
2
8
0 214
8
2
8
0 334
8
2
8
0 766
8
2
8
0 83
8
2
8
0 5...

result:

ok 

Test #26:

score: 15
Accepted
time: 4ms
memory: 4112kb

input:

999
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
2
2
2
2
2
1
2
1
2
1
2
2
1
2
2
1
2
1
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 751
8
2
8
0 104
8
2
8
0 27
8
2
8
0 793
8
2
8
0 66
8
2
8
1 66
8
0 444
8
2
8
0 448
8
2
8
0 81
8
2
8
0 233
8
2
8
0 15
8
2
8
0 504
8
2
8
0 917
8
2
8
0 281
8
2
8
0 358
8
2
8
1 358
8
0 643
8
2
8
1 643
8
0 753
8
2
8
0 136
8
2
8
0 990
8
2
8
0 594
8
2
8
1 594
8
0 730
8
2
8
0 882
8
2
8
0 215
8
2
8
1 215
8...

result:

ok 

Test #27:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

input:

999
1
1
1
1
1
1
1
1
1
2
1
1
2
2
2
1
1
2
2
2
2
2
2
1
1
2
1
1
1
1
2
2
2
2
2
2
2
2
2
1
1
2
1
2
2
2
1
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
1
1
2
2
1
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

output:

8
0 751
8
2
8
0 104
8
2
8
0 27
8
2
8
0 793
8
2
8
0 66
8
2
8
0 444
8
2
8
0 448
8
2
8
0 81
8
2
8
0 233
8
2
8
0 15
8
2
8
1 15
8
0 504
8
2
8
0 917
8
2
8
0 281
8
2
8
1 281
8
0 358
8
2
8
1 358
8
0 643
8
2
8
1 643
8
0 753
8
2
8
0 136
8
2
8
0 990
8
2
8
1 990
8
0 594
8
2
8
1 594
8
0 730
8
2
8
1 730
8
0 882
8...

result:

wrong answer Wrong answer.

Subtask #3:

score: 0
Wrong Answer

Test #43:

score: 75
Accepted
time: 1ms
memory: 3896kb

input:

2
1
2
2
2

output:

8
0 1
8
2
8
0 0
8
2
8
1 0
8
0 0
8
2
8
1 0
8
0 0
8
2
8
3 2

result:

ok 

Test #44:

score: 75
Accepted
time: 1ms
memory: 3828kb

input:

2
1
1

output:

8
0 1
8
2
8
0 0
8
2
8
3 1

result:

ok 

Test #45:

score: 75
Accepted
time: 1ms
memory: 3976kb

input:

3
1
1
2
2

output:

8
0 1
8
2
8
0 0
8
2
8
0 2
8
2
8
1 2
8
0 2
8
2
8
1 2
8
3 1

result:

ok 

Test #46:

score: 75
Accepted
time: 1ms
memory: 3956kb

input:

6
1
2
2
2
2
1
2
3
3
3
2
2
2
2

output:

8
0 1
8
2
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
0 5
8
2
8
1 5
8
0 4
8
2
8
1 4
8
0 2
8
2
8
0 0
8
2
8
0 3
8
2
8
1 3
8
0 5
8
2
8
1 5
8
0 4
8
2
8
1 4
8
0 0
8
2
8
1 0
8
0 3
8
2
8
1 3
8
0 5
8
2
8
1 5
8
0 4
8
2
8
1 4
8
3 1

result:

ok 

Test #47:

score: 75
Accepted
time: 1ms
memory: 3896kb

input:

10
1
1
2
2
2
2
2
2
2
2
2
3
4
3
4
3
4
4
4
5
4
5
5
6

output:

8
0 7
8
2
8
0 6
8
2
8
0 8
8
2
8
1 8
8
0 5
8
2
8
1 5
8
0 4
8
2
8
1 4
8
0 2
8
2
8
1 2
8
0 9
8
2
8
1 9
8
0 1
8
2
8
1 1
8
0 3
8
2
8
1 3
8
0 0
8
2
8
1 0
8
0 8
8
2
8
0 5
8
2
8
0 4
8
2
8
1 4
8
0 2
8
2
8
0 9
8
2
8
1 9
8
0 1
8
2
8
0 3
8
2
8
1 3
8
0 0
8
2
8
1 0
8
0 4
8
2
8
0 9
8
2
8
1 9
8
0 3
8
2
8
0 0
8
2
8
...

result:

ok 

Test #48:

score: 75
Accepted
time: 0ms
memory: 3912kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1286
8
2
8
0 293
8
2
8
1 293
8
0 249
8
2
8
1 249
8
0 1249
8
2
8
1 1249
8
0 66
8
2
8
1 66
8
0 531
8
2
8
1 531
8
0 352
8
2
8
1 352
8
0 1015
8
2
8
1 1015
8
0 232
8
2
8
1 232
8
0 1617
8
2
8
1 1617
8
0 1027
8
2
8
1 1027
8
0 916
8
2
8
1 916
8
0 1189
8
2
8
1 1189
8
0 21
8
2
8
1 21
8
0 1690
8
2
8
1 1690...

result:

ok 

Test #49:

score: 75
Accepted
time: 0ms
memory: 3920kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

8
0 517
8
2
8
0 888
8
2
8
0 1582
8
2
8
0 1843
8
2
8
0 762
8
2
8
0 1067
8
2
8
0 1903
8
2
8
0 1308
8
2
8
0 1645
8
2
8
0 1447
8
2
8
0 1075
8
2
8
0 224
8
2
8
0 281
8
2
8
0 1126
8
2
8
0 1752
8
2
8
0 1492
8
2
8
0 378
8
2
8
0 466
8
2
8
0 1491
8
2
8
0 1507
8
2
8
0 30
8
2
8
0 631
8
2
8
0 218
8
2
8
0 1152
8
2...

result:

ok 

Test #50:

score: 75
Accepted
time: 11ms
memory: 3936kb

input:

2000
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2
2
1
1
1
2
1
1
1
1
1
1
1
2
1
2
2
2
1
2
2
1
1
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
1
1
1
1
2
2
1
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
1
2
2
2
1
2
2
2
2
1
2
1
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 517
8
2
8
0 888
8
2
8
0 1582
8
2
8
0 1843
8
2
8
0 762
8
2
8
0 1067
8
2
8
0 1903
8
2
8
1 1903
8
0 1308
8
2
8
0 1645
8
2
8
0 1447
8
2
8
0 1075
8
2
8
0 224
8
2
8
0 281
8
2
8
0 1126
8
2
8
0 1752
8
2
8
0 1492
8
2
8
1 1492
8
0 378
8
2
8
1 378
8
0 466
8
2
8
0 1491
8
2
8
0 1507
8
2
8
0 30
8
2
8
1 30
8
0...

result:

ok 

Test #51:

score: 70.58
Acceptable Answer
time: 7ms
memory: 3912kb

input:

2000
1
1
1
1
1
2
1
1
1
2
1
1
1
1
2
1
2
2
1
1
1
1
2
1
1
2
2
2
1
1
2
1
2
2
2
1
2
1
2
2
2
2
2
2
1
2
2
1
2
2
1
1
2
1
2
1
2
2
2
1
2
2
2
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
1
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 517
8
2
8
0 888
8
2
8
0 1582
8
2
8
0 1843
8
2
8
0 762
8
2
8
0 1067
8
2
8
1 1067
8
0 1903
8
2
8
0 1308
8
2
8
0 1645
8
2
8
0 1447
8
2
8
1 1447
8
0 1075
8
2
8
0 224
8
2
8
0 281
8
2
8
0 1126
8
2
8
0 1752
8
2
8
1 1752
8
0 1492
8
2
8
0 378
8
2
8
1 378
8
0 466
8
2
8
1 466
8
0 1491
8
2
8
0 1507
8
2
8
0 ...

result:

points 0.94106666670 points  0.94106666670

Test #52:

score: 25.03
Acceptable Answer
time: 39ms
memory: 3940kb

input:

2000
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 517
8
2
8
0 888
8
2
8
1 888
8
0 1582
8
2
8
1 1582
8
0 1843
8
2
8
1 1843
8
0 762
8
2
8
1 762
8
0 1067
8
2
8
1 1067
8
0 1903
8
2
8
1 1903
8
0 1308
8
2
8
1 1308
8
0 1645
8
2
8
1 1645
8
0 1447
8
2
8
1 1447
8
0 1075
8
2
8
1 1075
8
0 224
8
2
8
1 224
8
0 281
8
2
8
1 281
8
0 1126
8
2
8
1 1126
8
0 1752
8...

result:

points 0.33373333330 points  0.33373333330

Test #53:

score: 75
Accepted
time: 0ms
memory: 3876kb

input:

2000
1
2
1
1
1
2
1
2
2
2
2
2
1
1
2
1
1
2
1
2
2
2
1
1
2
2
2
1
2
1
1
1
2
1
1
1
1
2
2
1
1
1
1
1
1
2
1
1
1
1
2
2
1
1
2
1
2
1
2
2
2
1
1
2
1
1
1
1
1
2
1
1
1
1
2
2
2
1
1
2
1
1
2
1
2
1
1
1
2
2
1
2
1
1
1
1
2
2
1
1
2
1
1
1
1
2
2
1
2
1
1
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
1
2
1
2
2
2
1
2
1
1
1
1
1
1
1
2
1
1
1
1
1
2...

output:

8
0 99
8
2
8
0 431
8
2
8
1 431
8
0 932
8
2
8
0 494
8
2
8
0 988
8
2
8
0 1333
8
2
8
1 1333
8
0 1678
8
2
8
0 1523
8
2
8
1 1523
8
0 1080
8
2
8
1 1080
8
0 648
8
2
8
1 648
8
0 1025
8
2
8
1 1025
8
0 1252
8
2
8
1 1252
8
0 1477
8
2
8
0 464
8
2
8
0 1608
8
2
8
1 1608
8
0 692
8
2
8
0 403
8
2
8
0 1707
8
2
8
1 17...

result:

ok 

Test #54:

score: 28.2
Acceptable Answer
time: 16ms
memory: 3848kb

input:

2000
1
2
1
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 99
8
2
8
0 431
8
2
8
1 431
8
0 932
8
2
8
0 494
8
2
8
0 988
8
2
8
1 988
8
0 1333
8
2
8
1 1333
8
0 1678
8
2
8
1 1678
8
0 1523
8
2
8
1 1523
8
0 1080
8
2
8
1 1080
8
0 648
8
2
8
1 648
8
0 1025
8
2
8
1 1025
8
0 1252
8
2
8
1 1252
8
0 1477
8
2
8
1 1477
8
0 464
8
2
8
1 464
8
0 1608
8
2
8
0 692
8
2
8
1 69...

result:

points 0.3760 points  0.3760

Test #55:

score: 57.87
Acceptable Answer
time: 25ms
memory: 3984kb

input:

2000
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
1
1
1
1
2
2
1
1
2
2
2
2
1
1
2
2
1
2
1
2
2
2
2
2
2
2
1
1
1
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
1
2
2
2
2
1
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
1
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 773
8
2
8
0 1872
8
2
8
0 987
8
2
8
0 1955
8
2
8
0 916
8
2
8
0 134
8
2
8
0 1976
8
2
8
0 73
8
2
8
0 5
8
2
8
0 967
8
2
8
0 520
8
2
8
0 1932
8
2
8
0 754
8
2
8
0 1432
8
2
8
0 1204
8
2
8
0 1762
8
2
8
0 1834
8
2
8
0 913
8
2
8
0 1742
8
2
8
0 464
8
2
8
1 464
8
0 1751
8
2
8
1 1751
8
0 542
8
2
8
1 542
8
0 ...

result:

points 0.77160 points  0.77160

Test #56:

score: 0
Wrong Answer
time: 12ms
memory: 3912kb

input:

1998
1
2
1
1
2
1
2
2
2
2
2
2
2
2
2
2
1
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2...

output:

8
0 1545
8
2
8
0 1689
8
2
8
1 1689
8
0 1476
8
2
8
0 573
8
2
8
0 1748
8
2
8
1 1748
8
0 109
8
2
8
0 636
8
2
8
1 636
8
0 1965
8
2
8
1 1965
8
0 1685
8
2
8
1 1685
8
0 962
8
2
8
1 962
8
0 1123
8
2
8
1 1123
8
0 1659
8
2
8
1 1659
8
0 24
8
2
8
1 24
8
0 11
8
2
8
1 11
8
0 776
8
2
8
1 776
8
0 903
8
2
8
1 903
8
...

result:

wrong answer Wrong answer.